Learning Parseltongue: Wizardry in Python
summary
Covers concrete Python magic methods and metaprogramming with working examples: a file wrapper that closes on __del__, word objects compared by length using functools.total_ordering, context managers that open and close connections via __enter__/__exit__, descriptors implementing get and set, custom pickling with __getstate__/__setstate__ to store history, and metaclasses created with type(name, bases, dict) plus __prepare__ using OrderedDict, including registry, final class and singleton patterns and a note that these work but can confuse readers.
AI-written summary · about
chapters (18)
- 0:00Intro
- 1:04MAGIC METHODS?!
- 1:27CONSTRUCTION AND INITIALIZATION
- 2:53COMPARISON MAGIC METHODS
- 4:38NORMAL ARITHMETIC OPERATORS
- 4:54REFLECTED ARITHMETIC OPERATORS
- 5:26AUGMENTED ASSIGNMENT .
- 5:40TYPE CONVERSION MAGIC METHODS
- 6:03REPRESENTING CUSTOM CLASSES
- 6:37ATTRIBUTE ACCESS
- 8:25CONTAINER MAGIC METHODS
- 9:26CONTEXT MANAGERS
- 10:42COPYING OBJECTS
- 11:24PICKLING
- 12:18ABSTRACT BASE CLASSES
- 14:28CUSTOM METACLASSES
- 15:15REGISTERING SUBCLASSES
- 18:21QUESTIONS?








