October 2018
Beginner to intermediate
466 pages
12h 2m
English
Think of the property function as returning an object that proxies any requests to set or access the attribute value through the methods we have specified. The property built-in is like a constructor for such an object, and that object is set as the public-facing member for the given attribute.
This property constructor can actually accept two additional arguments, a delete function and a docstring for the property. The delete function is rarely supplied in practice, but it can be useful for logging the fact that a value has been deleted, or possibly to veto deleting if we have reason to do so. The docstring is just a string describing what the property does, no different from the docstrings we discussed in Chapter 2 ...