Functional Programming inside OOP? It’s possible with Python
summary
Argues that Python’s OOP can adopt concrete functional techniques and shows tools and examples: uses functools.partial, generators/yield for lazy evaluation, type hints and Python 3.10 structural pattern matching, and operator and reduce-based composition to replace loops (example: refactor of Django code). Implements a concrete Maybe monad class with bind and an overridden __or__ operator to pipe functions so chains return Nothing instead of raising errors, and demonstrates that small pure functions make unit testing far simpler.
AI-written summary · about
chapters (33)
- 0:00Intro
- 1:03About me
- 1:56Why Functional Programming
- 2:54Origins of Functional Programming
- 5:10Django example
- 5:40Immutability
- 6:45Mutual Structure
- 7:37In introspection
- 7:53Curators
- 9:06Syntax
- 10:56Evaluation
- 11:38Generator
- 12:22Type annotations
- 13:11Github
- 13:56Structural pattern matching
- 15:07Match logic
- 16:37Match wildcard
- 17:19Other programming languages
- 17:40Current
- 18:51Examples
- 19:09One argument function
- 19:46decorator
- 20:15composition
- 22:42compose
- 23:27monets
- 26:03introspection
- 26:33review
- 27:16conversion rate
- 28:40binding functions
- 29:50magic method
- 30:09chaining
- 30:25testing
- 31:39positional programming
