Share E-Book

Functional Python Programming Use a functional approach to write succinct, expressive, and efficient Python code, 3rd Edition (Steven F. Lott)(Z-Library)

Author Steven F. Lott

Programming
Language English

This book provides detailed guidance on how to use Python’s functional programming features (with Python 3.10 examples, also tested with Python 3.11). Table of Contents: - Understanding Functional Programming - Introducing Essential Functional Concepts - Functions, Iterators, and Generators - Working with Collections - Higher-Order Functions - Recursions and Reductions - Complex Stateless Objects - The Itertools Module - Itertools for Combinatorics – Permutations and Combinations - The Functools Module - The Toolz Package - Decorator Design Techniques - The PyMonad Library - The Multiprocessing, Threading, and Concurrent.Futures Modules - A Functional Approach to Web Services - Bonus Online Chapter

Format EPUB
Size 4.7 MB
8
Views
0
Downloads
0.00
Total Donations

AI Guide

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

Full assistant
AI guide
【One-Line Pitch】 A practical guide to writing cleaner, more expressive Python by borrowing functional programming techniques—immutability, higher-order functions, lazy evaluation, and function composition—without abandoning Python's imperative and object-oriented strengths. Best for intermediate Python developers who already know the language and want to add a functional toolkit to their everyday code. 【Book Arc】 - **Opening (~0%–10%)**: Frames what functional programming means in Python terms—expressions over state changes, pure functions, and why a mixed paradigm is realistic. Uses exploratory data analysis (EDA) as the running problem domain. - **Early (~10%–35%)**: Builds the essentials: first-class and pure functions, immutable data, strict vs. lazy evaluation, iterators and generators, working with collections, higher-order functions like map() and filter(), recursion and reductions, and stateless objects via tuples, NamedTuple, frozen dataclasses, and pyrsistent. - **Middle (~35%–55%)**: Moves into library tooling—the itertools module (including combinatorics like Cartesian products, permutations, and combinations), the functools module (cache, partial, reduce, singledispatch, total ordering), and the toolz package. - **Late (~55%–80%)**: Advanced design patterns—decorators as higher-order functions for cross-cutting concerns, composite design, and parameterized decorators; the PyMonad library for currying, functors, and monad bind(). - **Ending (~80%–100%)**: Applies functional thinking to concurrency (multiprocessing, threading, concurrent.futures) and web services (HTTP request-response, WSGI, services as functions), plus a bonus online chi-squared case study. 【Key Takeaways】 - **Functional programming in Python is a spectrum, not a switch** (Early): The book repeatedly stresses that Python is not purely functional; the goal is to selectively adopt functional techniques where they make code more readable and maintainable, while keeping imperative and OO features available. - **Immutability simplifies reasoning and enables safe concurrency** (Early–Late): Tuples, NamedTuple, frozen dataclasses, and pyrsistent objects avoid inconsistent state, and the concurrency chapter ties this directly to distributing workloads without poorly synchronized writes. - **Generators and lazy evaluation are Python's native path to functional data pipelines** (Early): Generator expressions and functions let you clean and transform raw data without materializing intermediate collections. - **Higher-order functions and function composition are the core building blocks** (Early–Middle): map(), filter(), custom functions that accept or return functions, and composition let you build small, understandable pieces and combine them. - **The standard library already ships serious functional tools** (Middle): itertools and functools cover iteration, combinatorics, memoization, partial application, reduction, and type-based dispatch—no third-party dependency required. - **Decorators are the practical face of higher-order functions** (Late): They handle cross-cutting concerns and composite design, and can be parameterized for more complex behavior. - **Monads and PyMonad are optional, advanced territory** (Late): Currying, functors, and bind() are presented as techniques for simulation and composition, not as required daily practice. - **Functional design pays off in concurrency and web services** (Ending): Stateless functions map naturally onto process pools and onto web services modeled as request-to-reply function pipelines. 【Reading Tips】 - **Deep-read Chapters 1–7** if you are new to functional thinking; this is where the mental model is built, and later chapters assume it. - **Skim or selectively read the library chapters (8–11)** based on what you actually use—itertools and functools are high-value; toolz is optional if you prefer the standard library. - **Treat PyMonad (Chapter 13) as optional** unless you are specifically interested in monadic composition; it is the most niche material in the book. - **Do the exercises and check the GitHub repository**: the book explicitly notes that partial solutions and unit tests are provided, and suggests using timeit to compare design alternatives. - **Keep the EDA domain in mind** as a unifying thread; it makes the functional examples concrete rather than abstract. 【Coverage Limits】 This guide is based on the table of contents, preface, and stratified excerpts; the excerpts do not cover detailed code examples, the bonus online chi-squared case study, or the full content of individual chapters, so chapter-level specifics beyond their stated topics are not summarized here.

Passage locations

Excerpt 1
7 Applying generators to built-in collections 3.8 Summary 3.9 Exercises Join our community Discord space Chapter 4: Working with Collections 4.1 An over...
View in text
Excerpt 2
iews and tech talks at conferences are available on YouTube. Alex’s proudest achievement are the articles that appeared in Bridge World (January and February...
View in text
Excerpt 3
programs that deal with collections or generator functions. Chapter  9 , Itertools for Combinatorics – Permutations and Combinations , covers the combin...
View in text
Excerpt 4
sn’t contain a tutorial introduction to the Python language. We assume the reader knows some Python. In many cases, if the reader knows a functional programm...
View in text

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
Back to List