Functional Python Programming

(Wang) #1

Introducing Some Functional


Features


Most of the features of functional programming are already first-class parts of Python.
Our goal in writing functional Python is to shift our focus away from imperative
(procedural or object-oriented) techniques to the maximum extent possible.


We'll look at each of the following functional programming topics:



  • First-class and higher-order functions, which are also known as
    pure functions.

  • Immutable Data.

  • Strict and non-strict evaluation. We can also call this eager vs.
    lazy evaluation.

  • Recursion instead of an explicit loop state.

  • Functional type systems.


This should reiterate some concepts from the first chapter. Firstly, that purely
functional programming avoids the complexities of explicit state maintained via
variable assignment. Secondly, that Python is not a purely functional language.


We don't offer a rigorous definition of functional programming. Instead, we'll
locate some common features that are indisputably important. We'll steer clear
of the blurry edges.

Free download pdf