April 2014
Beginner to intermediate
634 pages
15h 22m
English
Python has several built-in decorators that are part of the language. The @property, @classmethod, and @staticmethod decorators are used to annotate methods of a class. The @property decorator transforms a method function into a descriptor. We use this to give a method function the syntax of a simple attribute. The property decorator, when applied to a method, also creates an additional pair of properties that can be used to create a setter and deleter property. We looked at this in Chapter 3, Attribute Access, Properties, and Descriptors.
The @classmethod and @staticmethod decorators transform a method function into a class-level function. The decorated method can now be called from a class, not an object. In the case ...