Loading topic
@classmethod and @staticmethod are defined by how they differ from them. This chapter sets out the working model of instance methods and self that the rest of the tutorial relies on. It also covers the errors that confuse people most o7 min readself and no cls. Python skips its usual automatic first argument for it. This chapter covers how static methods are defined and called, what they can and cannot see, how they behave under inheritance, and 8 min read__init__ and instance methods, that you know @name decorator syntax, and that you have read the earlier chapter on what @classmethod is and how cls works. Here the focus is one use of class methods: building instances from inputs that `_init_6 min readself. It also assumes you know the difference between class attributes and instance attributes, and you can read @name decorator syntax. The earlier chapters introduced @classmethod and alternative constructors. This one cove7 min read__init__ method and instance methods that use self. You should know that @name above a function is a decorator. You should also know the difference between a class attribute and an instance attribute. Earlier chapters covered how `@cla8 min readself, cls, and the "no first argument" behavior of static methods. You will see that all three come from one rule, the descriptor protocol. Once you know it, you can predict what any attribute access on a class or instance returns.7 min read