Functional Programming with Python

Python is one of the most popular programming languages in the world today. Functional programming is also enjoying a resurgence of popularity. This course shows you how to marry the two and apply functional programming principles in Python.
Course info
Rating
(24)
Level
Advanced
Updated
Aug 2, 2017
Duration
1h 49m
Table of contents
Course Overview
Introducing Functional Programming
First Class Functions
Pure Functions
Immutable Variables
Lazy Evaluation
Recursion
Simplifying Condition Testing with Matching
Summary
Description
Course info
Rating
(24)
Level
Advanced
Updated
Aug 2, 2017
Duration
1h 49m
Description

Functional programming (or FP) is a fifty-year-old idea that is becoming more and more relevant in building low-fault, high-concurrency systems. In this course, Functional Programming with Python, you will learn six essential paradigms of FP and how to implement them in Python. You will learn how to recognize problems that lend themselves to functional solutions, how to implement them professionally, and how they can be used to make your programs more robust and succinct. When you're finished with this course, you will be well on your way to adapting a functional style of programming to your Python projects.

About the author
About the author

Gerald is a multiple-year of the Microsoft MVP award, Gerald has led introductory classes in Python and SQL for industry-sponsored events at Ryerson University, Toronto and the University of Toronto (his alma mater). 

More from the author
Managing SQL Server Database Concurrency
Intermediate
1h 45m
Jun 7, 2019
Getting Started with Python on SQL Server
Intermediate
1h 25m
Apr 18, 2018
More courses by Gerald Britton
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hello everyone, my name is Gerald Britton. I'm a senior solutions designer at TD Bank in Toronto, Canada, and a Pluralsight author. Welcome to my course: Functional Programming with Python. Perhaps you are a seasoned Python programmer, and have heard all the fuss about functional programming. Perhaps you feel a little bit left out since Python is not a pure FP language. Or maybe you're coming to Python from a functional language like Haskell, Scala, or F#, and you're wondering how to work in a language that seems to be lacking the things you take for granted in your favorite FP language. Whatever your background, this course will help you become a functional Python programmer. Some of the major topics that we will cover include an overview of functional programming principles, including higher-order functions, pure functions, recursion, immutability, and matching. A discussion of Python language constructs that are available out of the box to the aspiring FP programmer, and how to handle the difficulties of recursion and immutability in a language that appears to have no special facilities for unlimited recursion or immutable variables. All of these topics will be covered in the context of a business problem and order processing system so that you can see how to use these concepts in the real world. By the end of this course, you'd have learned how to apply functional techniques to make your programs more succinct, less error prone, and easier to reason about. Before beginning the course, you should be familiar with basic Python programming, including how to write classes, functions, and methods, and how to create and use modules and packages. Also be sure you have a good Python IDE ready to go. I'll be using Visual Studio code across platform IDE for all the demos in this course. I hope you'll join me on this journey to learn how to use Python with a functional style of programming in this course: Functional Programming with Python, at Pluralsight.

Introducing Functional Programming
Hi, my name is Gerald Britton. I'm a senior IT solutions designer and Pluralsight author. In this course, you'll learn about functional programming, or FP, as it is often called. FP is a programming paradigm. An approach to solving programming problems. Though functional programming has been around since the 1950s, it has been overshadowed by other programming styles. In this introductory module, I'll review the main programming paradigms that are used today, and then talk about the main principles behind FP. In succeeding modules, you'll see how to take a typical business system, an order processing system, and transform it to a functional style as each functional concept is introduced.

First Class Functions
Welcome back to the course: Functional Programming with Python. My name is Gerald Britton. First-class functions are functions that are treated as objects. That means that functions can take other functions as arguments and can also return functions. In Python this is easy since everything is an object. In fact, Python has had first-class function since the very beginning. In this module, you'll begin working with the example to be used throughout this course. I think it's important that you actually work the examples. Don't just watch the pictures go by. All the code is included in the course materials for you to play with. As you begin building and using higher order functions, both in the working example and in your own projects, you'll soon become skilled in the art and see opportunities to simplify your code using this powerful paradigm. The working example we will use consists of the central pieces to an order processing system. At its core, we'll have an order object which will host a list of order items along with a reference to a customer. There will also be various indicators such as expedited, shipped, an enterprise customer indicator, and an item backorder flag, along with other state information, like the order ID and the shipping address. Let's look at the code we're starting with.

Lazy Evaluation
Welcome back to the course: Functional Programming with Python. My name is Gerald Britton. Tell me something. Do you ever procrastinate? Are there jobs you know you have to do, but avoid putting off until the last possible minute? Paying taxes maybe, or cleaning out your bedroom. I know I'm guilty of doing that kind of thing. However, putting things off until absolutely necessary is not always a bad idea, especially if the job could be a big one and there's at least a chance that you may never have to do it at all. That's the idea behind lazy evaluation. Some operations are costly - perhaps in terms of memory, or CPU time, or disk IO, or network access. If those jobs can be postponed or even avoided altogether, there can be a positive benefit to the whole ecosystem. Let's dig a little deeper to understand the differences between lazy evaluation and its alter ego, strict evaluation.