This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Juchen Zeng
Recipients Juchen Zeng, docs@python, eric.araujo, ezio.melotti, georg.brandl
Date 2015-12-01.08:02:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448956970.84.0.677978683679.issue25772@psf.upfronthosting.co.za>
In-reply-to
Content
A few days ago, I was learning built-in type `super` through [python official doc](https://docs.python.org/2/library/functions.html#super).  
And I was mislead by its documentation, in the part of how `__mro__` resolution works. Below is the part which confuse me:

"""
super(type[, object-or-type])

# ISSUE IRRELEVANT DOC OMITTED

The __mro__ attribute of the type lists the method resolution search order used by both getattr() and super(). The attribute is dynamic and can change whenever the inheritance hierarchy is updated.
"""

From the description of the doc we can see that `super()` takes two arguments, the first is `type` and the second is an optional `object-or-type`. So, when I saw the doc statement: `The __mro__ attribute of the type lists the method resolution search order used by both getattr() and super(). `, I naturally thought here the `type` refers to the compulsory first `type` argument. But after doing a series of [experiments][EXP_REF]. It turns out in `super()` was using the second `type`'s `__mro__` attribute! And if the second argument is an object, it will use `object.__class__.__mro__` as its resolution order. Unless a learner experimented it throughly like me, he will have lots of difficulty to figured out that `type` mentioned in the doc refers to the second optional argument. I think here the doc should be clearly specified that the second argument's `__mro__` is what super relies on. I suggest to add distinctions on arguments name or add more clarification informations in the doc here.

By the way, the python3 document has the same issue.  
If you decided to fix this, maybe you want to fix its python3 version, too.

 

[EXP_REF]: http://stackoverflow.com/questions/33890918/how-does-super-interacts-with-a-classs-mro-attribute-in-multiple-inheri/33891281#33891281
History
Date User Action Args
2015-12-01 08:02:50Juchen Zengsetrecipients: + Juchen Zeng, georg.brandl, ezio.melotti, eric.araujo, docs@python
2015-12-01 08:02:50Juchen Zengsetmessageid: <1448956970.84.0.677978683679.issue25772@psf.upfronthosting.co.za>
2015-12-01 08:02:50Juchen Zenglinkissue25772 messages
2015-12-01 08:02:49Juchen Zengcreate