June 2019
Beginner to intermediate
770 pages
19h 24m
English
When we have multiple ways to create an object, it's sometimes more clear to use static methods to create and return instances rather than complex __init__() methods.
The term static is borrowed from other languages. Python has three kinds of binding for method functions. The default case is to bind a method to the instance; the first positional parameter is self, the instance variable. A method can be bound to the class; this requires the @staticmethod decorator. A method can also be bound to the class, but receive the class as the first positional parameter; this requires the @classmethod decorator.
In the case of freezing or splitting a Hand object, we might want to create two new static ...
Read now
Unlock full access