Beyond Try-Except: The Frontier of Python Error Handling with Monads and Railway Magic
summary
Presents replacing try/except with a Result monad and Railway-oriented flow to make error handling predictable and more readable. Shows concrete Python code using the Results Library that returns Ok/Error for a validation → calculation → charge pipeline, plus file-read and DB-connection examples; demonstrates a decorator to wrap functions without massive refactors and uses pattern matching to separate success and failure paths, with a how-to for chaining operations and capturing errors without scattered exceptions.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:06Talk objectives
- 3:13Traditional Python error handling
- 8:47Limitations of traditional approaches
- 10:52Introduction to monads
- 15:25Railway Driven Development
- 16:27Traditional code example
- 21:22Monads and Railway Magic solution
- 24:51Pattern matching for errors
- 27:40Decorators and complex cases
- 29:04Key benefits
- 30:07Q&A
related talks
39mFunctional Error Handling in Python
31mFunctional Error Handling
31mGuardrails: An Alternative View of Safely Working in Python
32mMonads, in my Python?
31mGuardrails: An Alternative View of Safely Working in Python
46mOn Being Pythonic
33mElegant Solutions For Everyday Python Problems
29mWriting Functional Code in Python
