· 3 min read

Learn Python OOP: 59 Flashcards from __init__ and self to Dunder Methods and Metaclasses

Master Python OOP with 59 flashcards: classes, self, super() and MRO, @property, dunder methods, __slots__, dataclasses, ABCs and metaclasses, with study tips.

Python snake coiled around a tree of glowing class cubes linked by inheritance arrows, with flashcards

Studying. But it's also a video game. 🎮

Flashcards, quizzes and games that make you actually remember.

Start playing — it's free

Posted by

Python's object model looks simple — class, __init__, self — until you hit super(), the MRO, @property setters and dunder methods. Deck WX8019 "Python: OOP Fundamentals" packs that whole path into 59 cards, from your first class definition to descriptors and metaclasses. The content is accurate and code-heavy; here's how to get the most out of it.

Study this deck: Python: OOP Fundamentals

1 / 10
Question

Class in Python

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

Cards worth knowing by heart

FrontBack
instance vs class attributesInstance attributes are unique per instance (self.attr); class attributes are shared (ClassName.attr). Lookup checks the instance first, then the class.
Class methodsDecorated with @classmethod, take cls as first parameter, e.g. def from_string(cls, string):
MRO (Method Resolution Order)Order Python searches for methods; view with ClassName.mro(). Uses C3 linearization.
Name mangling__attribute becomes _ClassName__attribute. Avoids name clashes in inheritance, not security.
__str__ vs __repr____str__ is readable for users, __repr__ unambiguous for developers — and the fallback if __str__ is missing.
__new__ vs __init____new__ creates the instance, __init__ initializes it; __new__ runs first.
Slots in Python classes__slots__ restricts attributes, saves memory, no __dict__.
__getattr__ vs __getattribute____getattr__ is a fallback for missing attributes; __getattribute__ runs on every access.
MetaclassThe class of a class: class MyClass(metaclass=Meta).

What you'll cover

Classes and instances, self, __init__, instance, class and static methods, inheritance, method overriding, super(), multiple inheritance, MRO, polymorphism, duck typing, encapsulation, private attributes, name mangling, @property getters and setters, dunder methods (__str__, __repr__, __len__, __getitem__, __setitem__, __eq__ and the comparison family, __add__, __call__, __iter__, __next__, __enter__/__exit__, __hash__, __bool__, __del__), isinstance, issubclass, type, hasattr, getattr, setattr, delattr, __dict__, __class__, abstract base classes, @dataclass, the singleton pattern, composition over inheritance, method chaining, the descriptor protocol, __slots__ and metaclasses.

Study tips specific to this deck

Fix the capital letters as you go. Several fronts were auto-capitalized: Self, Super(), Isinstance(), Issubclass(), Hasattr(), Getattr(), Setattr(), Delattr(). Python is case-sensitive — Isinstance(x, int) raises NameError. Retype them as self, super(), isinstance() so you memorize the real spelling.

Pair the dunder cards with the operator they hook. Quiz yourself in reverse: see len(obj), obj[k] = v, a + b, with x: or obj() and name the method (__len__, __setitem__, __add__, __enter__/__exit__, __call__). That's how you'll meet them in real code.

Add one missing rule to the __hash__ card (54). "Immutable objects only" is too vague. The rule that bites people: if you define __eq__ without __hash__, Python sets __hash__ to None and your objects can no longer go in a set or be dict keys. Hash only on fields that never change. Also note the singleton card (50): hasattr(cls, 'instance') is also true for subclasses, so a subclass would return the parent's instance.

Card 56 on descriptors is the bridge to our Advanced Python decorators and descriptors guide; for the design side (composition, SOLID), continue with Design Patterns and SOLID.

Search for deck WX8019 in the library on Flip It.

Ready to learn faster? 🚀

Join FLIP IT for free and turn studying into a game.

Create my free account