A Lazy Person's Guide to Building REST Clients or: How I Learned to Stop Worrying and Love Dunder Ov
summary
Prototype overrides Python dunders to generate endpoints on demand: overrode __getattribute__ and __getattr__ and made instances callable via __call__, so attribute access like ip_addresses() formats a VirusTotal URL and issues a request with the requests library. The result is an endpoint class of about 80–100 lines that works, but requires fixes (double-creation bugs, returning JSON vs object, breaking instantiation if super is omitted). Notes use Python 3.10 pattern matching and caution that OpenAPI generators exist but can be unreliable.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:08REST clients are boring
- 4:56Problem case and approach
- 7:04Python’s dunder methods
- 9:10Dynamic attributes and methods
- 12:47Objects as callables
- 15:37REST client prototype
- 17:24Expanding functionality
- 19:11Validation and response handling
- 21:39Next steps and questions
- 22:22Q&A
related talks
26mDesigning Pythonic APIs
33mElegant Solutions For Everyday Python Problems
40mData Plumbing with Python
40mOh Python! Where Did We Go Wrong
01h 18mAPI design: Lessons Learned
32mPractical usage of advanced Python constructs
23mDjango REST API - So easy you can learn it in 25 minutes
50mDeveloping a RESTful Python service
