I am learning Python, and I am trying to understand descriptors better. When I look at this Python online book: http://www.cafepy.com/article/python_attributes_and_methods/ch01s05.html, it says:
- If attrname is a special (i.e. Python-provided) attribute for objectname, return it.
I don't understand what Python-provided means. Can someone give me an exemple of such Python-provided attribute that would take precedence over the usual resolution order?
Note: I am only interested in new-style classes (as descriptors don't even apply to old-style as far as I know).
__class__
, for instance:equivalent in old-style-classes:
while
There are many more special attribute names, depending on the type of the object. For instance, functions:
see http://docs.python.org/reference/datamodel.html for an overview
As you guessed, step 1 is flat-out wrong and doesn't exist.