Loading topic
__init__ and methods, and read and write instance attributes. You should also know how to raise and catch exceptions. Decorators are not needed yet. This chapter sets up the idea that the later chapters on naming conventions, name mangling, and @property5 min read__init__, set instance attributes, and import names from one module into another. You don't need properties yet. The chapter before this one covered what encapsulation means in Python. The chapters after it cover name mangling and @property.5 min read__init__, and use inheritance with super(). The previous chapters covered the single underscore convention. Here you will see what happens when an attribute name starts with two underscores, why Python does this,4 min read@property decorator, what Python does when you read the attribute, and the mistakes people most often make with a first getter.4 min read__init__, use the @ decorator syntax, and raise and catch exceptions. It also assumes you know the @property getter from the previous chapter. You will use a getter without a setter to make an attribute read-only. You will also see what that prot5 min read__init__, use the @ decorator syntax, and raise and catch exceptions. It also assumes you have seen a read-only @property getter, which the previous chapter covered. Here you add the other half: a setter, so that assignment to a public-looking at4 min read__init__, that you know the @property getter and @x.setter syntax, and that you can raise and catch exceptions. Here you learn why __init__ should assign through the public property name, and what goes wrong when it doesn't.4 min read__init__, you know the @ decorator syntax, and you have read the earlier chapters on the @property getter and read-only properties. Here you will use a getter to calculate a value from other attributes each time it is read.5 min read__init__, use @property with a getter and setter, and raise and catch exceptions. The earlier chapters showed what properties can do. This one covers when you should not use them.5 min read@property getters and setters, and that you know instance attributes live in obj.__dict__. You should also be able to read a basic decorator. The chapter covers what functools.cached_property does, how it works, where its cache goes stale, and when to pick it4 min read__init__, and that you know @property getters and setters from the earlier chapters. You should also be comfortable with try/except. Here you will learn what del obj.attr does when attr is a property, how to write a deleter, and where delet4 min read@property and @name.setter, and that you know a decorator is a function applied to the function below it. Here you will see that @property is shorthand for an ordinary call to the built-in property(). Knowing the call form explains several b4 min readsuper(). It covers what happens when a subclass defines or changes a property that a parent class already has. A few rules are unintuitive, and some of the mistakes fail silently.4 min read