June 2017
Beginner to intermediate
274 pages
6h 49m
English
Python's built-in @property decorator provides a simple way to create a descriptor. Let's consider an example (refer to the following code example) to illustrate this:

The first prop method we wrote in the preceding code example tells Python how to figure out the value of an attribute called prop, which in this case just means fetching it from another attribute and printing the value.
The latter two prop methods are decorated to turn them into setter and deleter for the prop attribute. This means that assigning a value to a prop actually means calling the setter method, and deleting a prop attribute actually ...
Read now
Unlock full access