Exploring Functional Options in Python
summary
Starts with a simple get_text function for a document‑analysis client, adds many parameters, and then explores designs: raw expanded signature, a pydantic config class for separated validation, a direct port of Go’s functional options (static methods that return callables applied to a headers dict), and finally a builder/chain that stores options in an object. The claim is that functional options work but feel un‑Pythonic; builder/chain gives localized docs, reasonable validation, and a simpler API after about a week of iteration.
AI-written summary · about
chapters (12)
- 0:00Introduction and speaker intro
- 1:49Problem and design goals
- 3:17Sam's initial simple solution
- 6:27Extending the function with more options
- 9:39Maintaining good code principles
- 10:43Improving with config classes
- 14:03Introducing functional options
- 18:59Method chaining and builder pattern
- 21:49Why Go prefers functional options
- 25:04Design evolution summary
- 27:36Key takeaways and resources
- 29:09Q&A session
related talks
02h 43mFunctional Python
39mFunctional Programming in Python
30mFunctional Programming in Python
27mFunctional Programming for Pythonistas
29mWriting Functional Code in Python
33mPythonic `functional` (`iter`)tools for your data challenges
46mOn Being Pythonic
28mSimplifying Python Code through the Lens of Functional Programming
