We may earn an affiliate commission when you visit our partners.
Packt Publishing

Python is not a functional programming language, but it is a multi-paradigm language that makes functional programming easy to perform, and easy to mix with other programming styles. Python is a high level language used in many development areas, like web development, data analysis, desktop UI and system administration. Functional programming is a style of programming that is characterized by short functions, lack of statements, and little reliance on variables. You will learn what functional programming is, and how you can apply functional programming in Python. If you're interested to use Functional Programming as a powerful tool to solve many real-world problems by writing robust and bug-free code, then go for this Learning Path.

Read more

Python is not a functional programming language, but it is a multi-paradigm language that makes functional programming easy to perform, and easy to mix with other programming styles. Python is a high level language used in many development areas, like web development, data analysis, desktop UI and system administration. Functional programming is a style of programming that is characterized by short functions, lack of statements, and little reliance on variables. You will learn what functional programming is, and how you can apply functional programming in Python. If you're interested to use Functional Programming as a powerful tool to solve many real-world problems by writing robust and bug-free code, then go for this Learning Path.

Packt’s Video Learning Paths are a series of individual video products put together in a logical and stepwise manner such that each video builds on the skills learned in the video before it.

The highlights of this Learning Path are:

  • Understand common functional design patterns, and how these apply to Python
  • Learn the important role that iterators play in functional programming

In this Learning Path, you’ll learn what functional programming is, and how it differs from other programming styles, such as procedural and object-oriented programming. Then you’ll go on to explore lambda expressions, which are short one-line functions, and are the purest form of functional programming that Python offers. Next, you’ll learn about higher-order functions: functions that accept other functions as an argument, or return other functions as return values. You’ll also encounter important concepts from functional programming, such as monads, currying, statelessness, side-effects, memorization, and referential transparency; these concepts may initially seem odd to Python programmers, but you’ll see how they are elegantly supported by the language.

Further, you’ll learn everything there is to know about iterators in Python and how crucial they are in functional programming, where they are used, among other things, to implement repetitive logic and coroutines. You’ll learn about all standard iterators and iterator functions that Python offers. You’ll also learn to implement your own iterators. Functional programming makes heavy use of iterators, and you’ll learn how you can use them in functional programming through an interactive calculator application.

By the end of this Learning Path, you will get a thorough understanding of iterators to solve many real-world problems by writing robust, testable, and bug-free code.

Meet Your Expert:

We have combined the best works of the following esteemed authors to ensure that your learning journey is smooth:

SebastiaanMathôt currently works as assistant professor at the University of Groningen in the Netherlands. He is the lead developer at OpenSesame, which is an open-source, Python-based program for implementing psychology and neuroscience experiments. Sebastiaan is also the designer of DataMatrix, a Python library for numeric computing that is focused on elegance and readability. Sebastiaan also gives regular workshops on using OpenSesame and Python for scientific purposes, and regularly publishes Python tutorials on his YouTube channel. As such, he has extensive experience in teaching Python and making advanced topics seem as easy as possible.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Higher-order functions and lambda expressions (nameless functions)
  • Error handling in functional programming
  • Understand common functional design patterns, and how these apply to python
  • Understand what an iterator is in python
  • Iterators and iterator functions built into python
  • Create your own iterators
  • Understand what a generator coroutine is
  • Master list and dict comprehensions and generator expressions

Syllabus

Functional Programming in Python

This video gives an overview of entire course.

In this video, we will consider iterator unpacking, a neat and, Python trick to assign multiple elements from an iterator to multiple variables – in a single statement.

Read more

In this video, we will see how a basic calculator application can be implement using two different programming styles, procedural and functional. By doing so, we will get a first taste of functional programming.

In this video, we will see what statelessness, side-effects, and referential transparency are.

In this video, we will consider two ways of testing code, unit testing and through formal proofs.

In this video, we will consider recursion (functions that call themselves), which is often used in functional programming instead of loops.

In this video, we will consider how functional programming doesn’t always match how humans think of the world as consisting of objects.

Functional programming relies heavily on expressions, and eschews statements. But what is the difference between the two? In this video, we will learn exactly how statements and expressions differ.

In this video, we will look at lambda expressions. This is the purest form of functional programming that Python offers. Lambda expressions are functions that consist of a single expression and which do not need to have a name. 

In this video, we will take a closer look at ‘and’ and ‘or’. 

In this video, we will consider ‘if’ expressions. These are the functional alternatives to the far more commonly used ‘if’ statements.

In this video, we will consider how you can pass a function as an argument to another function. The receiving function is by definition a higher-order function.

In this video, we will look at nested functions, that is, functions that are defined inside other functions. We will also consider variable scope, that is, from which functions variables are accessible. These are important concepts for higher order functions.

In this video, we will see how a higher-order function can return functions as return values.

Because operators (+, -, /, and so on) are syntax and not objects, you cannot pass them as arguments or return values. To bypass this problem, the Python operator module offers all operators also as functions.

In this video, we will consider decorators. Decorators are an elegant and Pythonic syntax to implement specific kinds of higher-level functions.

In this video, we will consider decorators that accept arguments. This makes the decorator design pattern even more flexible.

In this video, we will look at currying, a technique for turning a function that takes multiple arguments into a chain of function that each take one argument.

In this video, we will look at monads. Most discussions of monads are complicated, and use lots of mathematical terminology. But, as we will see in this video, the idea of monads is really simple.

In this video, we will look at memoization, which is a technique to optimize code by storing return values of functions.

In this video, we will look at exceptions, which are the standard Python approach to error handling.

In this video, we will look at an alternative approach to error handling, using a Maybe-like decorator. This resembles the Maybe monad, but takes a more Pythonic approach.

In this video, we will take everything that we’ve learned, and use this newly acquired knowledge to polish the interactive calculator that we developed at the start of this section with the help of all using a functional programming style.

Iterators in Functional Programming with Python

In this video, we will first introduce important concepts –iterators, mutability, and order. Next, we will consider Python’s most common built-in iterator – the list.

In this video, we will take a look at the tuple, another very common iterator. We also consider some things you can do with Iterators in general (not only tuples).

In this video, we will consider the dict, another common Python iterator; but very different from lists and tuples.

In this video, we will introduce the set, another built-in iterator, but one that is focused more on mathematical situations.

In this video, we consider theiterator protocol, which formally defines iterator objects, and describes the (minimum) functionality that iterators provide.

In this video, we will see how you can write a class that implements theiterator protocol.

In this video, we will considergenerators, which are functions that implement theiterator protocol in an elegant and simple way.

In this video, we will show how you can use generators to implement lazy evaluation – evaluating elements from aniterator only if and when they are required.

In this video, we will consider generator coroutines, which are generator functions that run in rapidly alternating suspend-resume cycles. This is sometimes called light-weight threading.

In this video, we will consider the collections module, which is part of the Python standard library, and which provides several convenient predefined iterator objects.

In this video, we first consider the difference between statements and expression. We then look at the list comprehension, which is an expressive alternative to the ‘for’ statement.

In this video, we will look at the Dict comprehension, which is similar to the list comprehension, but for Dict objects.

In this video, we will considergenerators expressions which are similar to list comprehensions but use generator.

In this video, we will look at nested loops. Nested loops (that is a ‘for’ loop within a ‘for’ loop) are mostly used when you need all possible combinations of the elements of two lists. Nested comprehensions allow you to implement this very elegantly.

In this video, we will look at four functions for working with iterators that are built into Python: zip(), map(), enumerate(), and filter().

In this video, we will look at several built-in functions for performing numerical and logical operations on iterators.

In this video, we will consider the most important functions from the itertools module, which is part of the Python standard library. The itertools module provides many convenient functions for working with iterators. 

In this video, we first consider higher-order functions, which are functions that use other functions as arguments or return values. Then we move on to consider the most important functions from the functools module, which is part of the Python standard library, and provides convenient higher-order functions.

In this video, we will consider generator coroutines, which are generator functions that run in rapidly alternating suspend-resume cycles. This is sometimes called light-weight threading.       

In this video, we will consider good coding practice. For most problems, many different solutions exist. In this course, we have considered solutions that rely on iterators. But, while iterators are powerful, they are not always the best solution to a given problem.

In this video, we will consider an interactive calculator that is implemented using a sensible mix of programming techniques, including those that we’ve learned in this course.

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Explores functional programming concepts like lambda expressions, higher-order functions, and monads, which can enhance code clarity and efficiency for Python developers
Covers iterators and generators in depth, which are essential tools for memory-efficient and elegant code in Python, especially when dealing with large datasets
Examines practical applications of functional programming by building an interactive calculator, which reinforces theoretical concepts with hands-on experience
Discusses error handling techniques specific to functional programming, which can help developers write more robust and reliable Python code
Requires familiarity with Python syntax and basic programming concepts, which may pose a challenge for individuals new to programming
Teaches the use of the 'operator' and 'itertools' modules, which are standard libraries that can greatly simplify functional programming tasks in Python

Save this course

Save LEARNING PATH: Python: Functional Programming with Python to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in LEARNING PATH: Python: Functional Programming with Python with these activities:
Review Python Fundamentals
Solidify your understanding of fundamental Python concepts like data types, control flow, and basic syntax. This will provide a strong foundation for understanding functional programming concepts in Python.
Browse courses on Python Basics
Show steps
  • Review Python documentation on data types and operators.
  • Practice writing simple Python functions.
  • Complete online Python tutorials for beginners.
Explore 'Functional Programming in Python' by David Mertz
Gain a deeper understanding of functional programming principles and techniques. This will help you write more elegant and efficient Python code.
Show steps
  • Read the chapters on higher-order functions and currying.
  • Study the examples of monads in Python.
  • Consider how these concepts can be applied to your own projects.
Read 'Fluent Python'
Deepen your understanding of Python's advanced features, including iterators, generators, and decorators. This will provide a solid foundation for understanding and applying functional programming principles.
Show steps
  • Read the chapters on iterators and generators.
  • Experiment with the code examples in the book.
  • Reflect on how the concepts relate to functional programming.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Implement Functional Programming Exercises
Reinforce your understanding of functional programming concepts by implementing practical exercises. This will help you solidify your knowledge and develop your problem-solving skills.
Show steps
  • Solve functional programming problems on platforms like HackerRank or LeetCode.
  • Implement solutions using lambda expressions and higher-order functions.
  • Compare your solutions with others to learn different approaches.
Write a Blog Post on Functional Programming in Python
Solidify your understanding of functional programming by explaining the concepts in your own words. This will help you identify any gaps in your knowledge and improve your communication skills.
Show steps
  • Choose a specific aspect of functional programming in Python.
  • Research the topic and gather relevant information.
  • Write a clear and concise blog post explaining the concept.
  • Include code examples to illustrate your points.
Build a Data Processing Pipeline with Functional Programming
Apply your knowledge of functional programming to a real-world problem. This will help you develop your skills in designing and implementing functional solutions.
Show steps
  • Define the requirements for your data processing pipeline.
  • Design the pipeline using functional programming principles.
  • Implement the pipeline using Python's functional programming features.
  • Test and debug your pipeline.
Contribute to a Functional Python Library
Enhance your understanding of functional programming by contributing to an open-source project. This will give you practical experience working with functional code and collaborating with other developers.
Show steps
  • Find an open-source Python library that uses functional programming.
  • Identify a bug or feature that you can contribute.
  • Submit a pull request with your changes.
  • Respond to feedback from the maintainers.

Career center

Learners who complete LEARNING PATH: Python: Functional Programming with Python will develop knowledge and skills that may be useful to these careers:
Python Developer
A Python developer specializes in building applications and software using the Python programming language and needs a strong grasp of functional programming. This course provides a comprehensive introduction to functional programming concepts such as lambda expressions, higher-order functions, and iterators, all within the Python context. A Python developer can leverage the course's in-depth exploration of function design patterns, statelessness, and error handling to write cleaner and more efficient Python code. Additionally, the course's focus on iterators and generator coroutines will help a Python developer create more robust and scalable applications.
Software Developer
A software developer designs, codes, and tests software applications. This course, focusing on functional programming in Python, is directly applicable to a software developer's daily tasks. The course material on functional design patterns and iterators helps developers write concise, readable and bug-free code which is particularly important in software development. Knowledge of lambda expressions, higher-order functions and generator coroutines help a software developer create robust and maintainable applications. The course specifically covers the use of Python for functional programming, which provides a different approach to problem-solving in comparison to other programming styles.
Data Scientist
A data scientist uses programming and statistical techniques to analyze data and extract insights. This course may be useful as it teaches functional programming in Python, a vital skill for data scientists. The course's focus on iterators, higher order functions, and functional programming design patterns enhances a data scientist's capability to manipulate and process data efficiently. The course also covers the use of list, dict comprehensions and generator expressions, which are commonly used for working with data in Python. The course's emphasis on writing robust and easily testable code is also beneficial for data scientists who work with large datasets and require clean analysis.
Research Scientist
A research scientist conducts research in various scientific fields, often involving data analysis and computational work. This course may be useful, because a research scientist, especially in fields that use computational modeling, can benefit from the functional programming approach to data processing and analysis. The course's focus on functional programming in Python, especially on iterators, higher-order functions, and lambda expressions, helps scientists write efficient and readable code for their data processing pipelines. The course is particularly helpful because it introduces design principles useful for scientific computing. Many research scientists work with Python.
Web Developer
A web developer builds and maintains websites and web applications. This course may be useful for a web developer who wants to leverage Python for backend development. The course’s exploration of functional programming techniques, higher-order functions, and iterators, allows a web developer to write robust and well-structured code. This course helps a web developer solve problems. The course also covers more advanced concepts like generator coroutines, which may improve a web developer's capacity to build scalable and effective web services.
Data Analyst
A data analyst examines data to identify trends and insights. This course may be useful to a data analyst by teaching Python, which is a powerful tool for data analysis. This course explores functional programming in the Python language, which promotes concise and efficient data manipulation. Understanding functional programming concepts, including higher order functions and lambda expressions, provides a data analyst with additional techniques to process and analyze data. The course's focus on iterators and Python's comprehensions also helps the data analyst manage and explore datasets effectively.
DevOps Engineer
A DevOps engineer manages and automates software deployment and infrastructure. This course may be useful because the functional programming techniques explored in the course can be applied to scripting and automation tasks. The course's focus on iterators, higher-order functions, and statelessness can assist a devops engineer in writing cleaner and more efficient code for configuration management and system automation. The course specifically teaches the use of Python in functional programming, Python being a common language in devops tasks. The course's emphasis on writing testable, bug-free code using functional programming principles helps a devops engineer improve system stability.
Bioinformatician
A bioinformatician analyzes biological data using computational tools. This course may be useful as a bioinformatician often works with Python to manage and transform biological datasets. The course's focus on functional programming, including iterators, higher-order functions, and lambda expressions, enables the bioinformatician to write efficient code. The course's emphasis on writing robust code, and its exploration of functional design patterns, may help a bioinformatician manage complex biological data. The course may also help the bioinformatician apply a different paradigm to problem solving. While this course does not focus on bioinformatics specifically, the programming skills developed are readily applicable.
Machine Learning Engineer
A machine learning engineer develops and deploys machine learning models. This course may be useful because a machine learning engineer often needs to preprocess data and implement complex algorithms, for which functional programming techniques can be highly efficient. The course's focus on iterators, higher-order functions, and lambda expressions will help a machine learning engineer write more concise and maintainable code for machine learning tasks. The course helps a machine learning engineer perform data analysis with functional programming. While this course does not cover machine learning directly, the programming and problem solving skills cultivated here are applicable to the field of machine learning.
Quantitative Analyst
A quantitative analyst develops and implements mathematical models for financial analysis. This course may be useful as a quantitative analyst often requires strong programming skills. The functional programming in Python taught by this course offers a powerful approach to numerical analysis and algorithm implementation, with concepts like statelessness and pure functions being useful for building reliable models. The course's focus on higher-order functions, lambda expressions, and iterators provides tools for data processing. This course may help a quantitative analyst improve their skills with Python for financial modeling tasks.
Algorithm Developer
An algorithm developer constructs and implements algorithms for problem solving. This course may be useful, as the functional programming paradigms explored, including the use of iterators and statelessness, can help design more elegant and maintainable algorithms. The course's focus on higher-order functions and recursion also provides an alternate approach to problem solving that an algorithm developer may readily apply. This course also includes material on code optimization using memoization. The course's exploration of functional programming techniques in Python can help an algorithm developer write efficient algorithms, particularly when working with complex datasets.
Game Developer
A game developer creates video games for various platforms. This course may be useful because the functional programming skills learned can be applicable to game logic and data handling. The course's emphasis on iterators, generator coroutines, and functional design patterns allows a game developer to write robust and efficient game code. The course also teaches efficient use of Python for complex game mechanics. Although this course does not specifically focus on game development, it may help a game developer work with game logic effectively.
Robotics Engineer
A robotics engineer designs and builds robots, a discipline that includes software development. This course may be useful, because it introduces functional programming principles that can be applied to robot control and data processing. The course’s use of Python, a language often used in robotics, in conjunction with the course’s teachings on iterators, higher-order functions, and generator coroutines can help robotics engineers write more efficient and maintainable code. The course helps a robotics engineer apply program structure to data processing tasks.
Embedded Systems Engineer
An embedded systems engineer designs and develops software for embedded systems. This course may be useful due to the emphasis on functional programming principles and their applicability to real-world problem-solving. The course's focus on concise, testable, and bug-free code using techniques such as higher-order functions, lambda expressions, and iterators can be particularly valuable in constrained embedded environments. The course teaches the use of Python for functional programming. While embedded systems programming often involves C or C++, this course helps an embedded systems engineer apply program structure.
Academic Professor
An academic professor teaches and conducts research at a university. Although this course may be useful, it will likely not be a primary tool for an academic professor. The course's exploration of functional programming in Python may help a professor teach programming concepts more effectively. The course also provides experience with functional programming and its application to different kinds of problems. This course may also be useful to a professor who uses Python in their research. The course may help build a professor’s knowledge of the language. This role typically requires an advanced degree.

Reading list

We've selected two books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in LEARNING PATH: Python: Functional Programming with Python.
Provides a deep dive into Python's core features, including iterators, generators, and functional programming constructs. It's an excellent resource for understanding how to write idiomatic and efficient Python code. It expands on the course material by providing practical examples and advanced techniques. This book is commonly used by intermediate to advanced Python programmers.
Provides a comprehensive guide to functional programming techniques in Python. It covers topics such as higher-order functions, currying, and monads. It's a valuable resource for understanding the theoretical foundations of functional programming and how to apply them in Python. This book adds more depth to the course by exploring advanced functional programming concepts.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser