Master Advanced Python: 97 Flashcards on Decorators, Descriptors, Lambdas and Exceptions
Master advanced Python with 97 flashcards: metaclasses, descriptors, MRO, decorators, lambdas and exceptions, plus three buggy snippets you should fix first.

Studying. But it's also a video game. 🎮
Flashcards, quizzes and games that make you actually remember.
Posted by
Related reading
Learn Python OOP in German: 59 Flashcards on Klassen, Vererbung and Magische Methoden
Study Python OOP with German explanations: 59 real flashcards on Klassen, Vererbung, MRO, Kapselung and dunder methods, plus 4 cards to fix and überschreiben vs überladen.
Master Python OOP in Spanish: 59 Flashcards on Clases, Herencia and Métodos Mágicos
Learn Python object-oriented programming with Spanish explanations: 59 real flashcards on clases, herencia, MRO, métodos mágicos and the Spanish terms to know.
Learn Python OOP in French: 59 Flashcards on Classes, Héritage and Méthodes Magiques
Study Python object-oriented programming in French with deck EO1367: 59 flashcards on classes, self, super(), MRO, dunder methods, @property and metaclasses.
The title promises decorators, lambdas and exceptions — but the first half of Python: Advanced (code TQ3214, 97 cards) is actually Python's object model: metaclasses, descriptors, MRO and nearly every dunder method. That's good news if you're preparing for a senior interview, as long as you study it in the right order.
Study this deck: Python: Advanced (Decorators, Lambda & Exceptions)
1 / 10Metaclass in Python
Tap the card for the answer · swipe right if you knew it, left if not
The real map of the deck
- Cards 1-49 — object model: metaclasses,
__new__vs__init__, descriptors (data vs non-data), the attribute lookup order, MRO and C3 linearization,super(),__call__,__getattr__vs__getattribute__,__slots__,__str__vs__repr__, rich comparisons,__hash__,__bool__, reflected operators (__radd__), container protocol (__getitem__,__contains__,__iter__/__next__,__missing__),__index__,__init_subclass__,__class_getitem__,weakref, async protocols (__await__,__aenter__,__aiter__). - Cards 50-59, 74-79, 89-93 — decorators and lambdas: wrappers,
@desugaring, stacking order,@staticmethod/@classmethod,functools.wraps, decorators with arguments,@propertysetters,lru_cache, class-based decorators, closures,map/filter/sorted(key=…). - Cards 60-73, 80-88, 94-97 — exceptions:
try/except/else/finally, bareexcept:vsexcept Exception,raise … from, theBaseExceptiontree, custom exceptions,assertand-O, EAFP vs LBYL,contextlib.suppress,@contextmanager,ExceptionGroupandexcept*,traceback.
Sample cards
| Front | Back |
|---|---|
| Data vs non-data descriptors | Data (__set__/__delete__) beat the instance __dict__; non-data (__get__ only) lose to it |
| How does super() work? | Delegates to the next class in the MRO, not just the direct parent |
__setattr__ | self.x = y inside it recurses forever — use object.__setattr__ |
| Can you stack multiple decorators? | Yes; they apply bottom to top |
| Write a decorator that takes arguments | Three levels: repeat(n) → decorator(func) → wrapper |
except: vs except Exception: | Bare except also swallows SystemExit and KeyboardInterrupt |
| Raise from another exception | raise NewError(...) from original keeps the chain |
| ExceptionGroup (3.11+) | Multiple exceptions at once, caught with except* |
Study tips specific to this deck
Start at card 50, then go back. Decorators and exceptions are what you use daily; the object-model block makes far more sense afterward — a class-based decorator (card 92) is just __call__ (card 9), and @property (card 89) is just a descriptor (card 41). Tag those pairs so they come up together.
Run the snippets — three of them have traps:
- Card 63's
finallyexample opens the file insidetry: ifopen()fails,f.close()raisesNameError. Open beforetry, or usewith. - Card 51's wrapper erases
__name__and__doc__; card 74 (functools.wraps) is its fix — merge them. - Card 92's
CountCallsbreaks on methods (no__get__, so noself) and drops**kwargs.
Fix these cards
- Card 58 says lambdas "can't contain assignments", and card 77 shows a walrus inside a lambda. Rewrite 58 as "no assignment statements".
- Card 40 returns an
OrderedDictfrom__prepare__: the class namespace has been an ordereddictsince 3.6, so the example is outdated. - Card 19 omits the classic gotcha: defining
__eq__sets__hash__toNone, making instances unhashable. - Card 87: since 3.11,
sys.exception()is the simpler way to get the current exception. - Duplicates to suspend: 31/48 (
__del__), 68/80 (exception hierarchy), 41/89 (property).
For the foundations underneath this deck, see Python Data Structures and Comprehensions.
Look up TQ3214 – Python: Advanced (Decorators, Lambda & Exceptions) in the library on Flip It.
Ready to learn faster? 🚀
Join FLIP IT for free and turn studying into a game.