Loading topic
__init__ and regular methods. You should also know the basic built-in types (list, dict, tuple) and how for loops and with statements work.2 min read__init__ and instance attributes, and that you know f-strings and the built-in list type.2 min read__init__ sets up attributes. You will learn what happens before __init__ runs and when __new__ is worth writing.2 min read== works on your own classes, why __hash__ must match __eq__, and the errors that follow when it doesn't.2 min read__eq__ and __hash__ from the previous chapter. You should also be comfortable with tuples and with sorted().2 min read__init__ and regular methods, and that you know Python's built-in numeric types. It covers the special methods Python calls for if obj:, int(obj), float(obj), and for places that need a true integer, such as indexing.2 min readisinstance and basic tuple and list behavior. It covers the binary arithmetic hooks. Reflected operators, in-place operators and unary operators get their own chapters.2 min read__add__ and __mul__ on a class like Vector. Here you will see what happens when the left operand cannot handle the right one, and how NotImplemented makes your classes cooperate with other types.2 min read__init__ and __repr__, and that you know how Python maps + to __add__. Here you apply the same idea to operators that take one operand.2 min read__add__ and NotImplemented from the previous chapters, and that you understand the difference between mutable and immutable objects.2 min readlist, dict and tuple behave, and have used for loops. You will make your own class act like a sequence by adding a few special methods.2 min readfor loops and generators' yield at a basic level. It builds on the container chapter, where __getitem__ happened to make iteration work.2 min readwith open(...) as f:. It covers how the with statement calls special methods on your own classes.2 min read__dict__, and have read the chapters on __repr__ and __eq__. Here you will learn how Python looks up attributes and how __getattr__ and __setattr__ let you change that lookup.2 min read@property. A descriptor is an object that controls what happens when you read, assign, or delete an attribute on another class. You write the rule once and reuse it on many attributes.2 min read__repr__, __eq__, __hash__, the ordering methods, and the arithmetic and reflected operators. Here the question changes from how to overload to whether you should.2 min read