Functional Programming in Python
Free

Functional Programming in Python

By David Mertz
Free
Book Description

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. In this paper, David Mertz, a director of Python Software Foundation, examines the functional aspects of the language and points out which options work well and which ones you should generally decline.



Mertz describes ways to avoid Python’s imperative-style flow control, the nuances of callable functions, how to work lazily with iterators, and the use of higher-order functions. He also lists several third-party Python libraries useful for functional programming.



Topics include:


  • Using encapsulation and other means to describe "what" a data collection consists of, rather than "how" to construct a data collection

  • Creating callables with named functions, lambdas, closures, methods of classes, and multiple dispatch

  • Using Python’s iterator protocol to accomplish the same effect as a lazy data structure


  • Creating higher-order functions that take functions as arguments and/or produce a function as a result

Table of Contents
  • Copyright
  • Table of Contents
  • Preface
    • What Is Functional Programming?
    • Beyond the Standard Library
    • Resources
    • A Stylistic Note
  • Chapter 1. (Avoiding) Flow Control
    • Encapsulation
    • Comprehensions
      • Generators
      • Dicts and Sets
    • Recursion
    • Eliminating Loops
      • Eliminating Recursion
  • Chapter 2. Callables
    • Named Functions and Lambdas
    • Closures and Callable Instances
    • Methods of Classes
      • Accessors and Operators
      • Static Methods of Instances
      • Generator Functions
    • Multiple Dispatch
      • Many Branches
      • Delegating to the Object
      • Pattern Matching
      • Predicate-Based Dispatch
  • Chapter 3. Lazy Evaluation
    • The Iterator Protocol
    • Module: itertools
      • Chaining Iterables
  • Chapter 4. Higher-Order Functions
    • Utility Higher-Order Functions
    • The operator Module
    • The functools Module
    • Decorators
    No review for this book yet, be the first to review.
      No comment for this book yet, be the first to comment
      You May Also Like
      Also Available On
      App store smallGoogle play small
      Categories
      Curated Lists
      • Pattern Recognition and Machine Learning (Information Science and Statistics)
        by Christopher M. Bishop
        Data mining
        by I. H. Witten
        The Elements of Statistical Learning: Data Mining, Inference, and Prediction
        by Various
        See more...
      • CK-12 Chemistry
        by Various
        Concept Development Studies in Chemistry
        by John Hutchinson
        An Introduction to Chemistry - Atoms First
        by Mark Bishop
        See more...
      • Microsoft Word - How to Use Advanced Algebra II.doc
        by Jonathan Emmons
        Advanced Algebra II: Activities and Homework
        by Kenny Felder
        de2de
        by
        See more...
      • The Sun Who Lost His Way
        by
        Tania is a Detective
        by Kanika G
        Firenze_s-Light
        by
        See more...
      • Java 3D Programming
        by Daniel Selman
        The Java EE 6 Tutorial
        by Oracle Corporation
        JavaKid811
        by
        See more...