[ python-Bugs-973579 ] Doc error on super(cls,self)

SourceForge.net noreply at sourceforge.net
Tue Jun 15 18:43:24 EDT 2004


Bugs item #973579, was opened at 2004-06-15 15:43
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=973579&group_id=5470

Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David MacQuigg (macquigg)
Assigned to: Nobody/Anonymous (nobody)
Summary: Doc error on super(cls,self)

Initial Comment:
In both the Library Reference, section 2.1, and in the 
Python 2.2 Quick Reference, page 19, the explanation 
for this function is:

super( type[, object-or-type]) 
   Returns the superclass of type. ...

This is misleading.  I could not get this function to work 
right until I realized that it is searching the entire MRO, 
not just the superclasses of 'type'.  See 
comp.lang.python 6/11/04, same subject as above, for 
further discussion and an example.

I think a better explanation would be:

super(cls,self).m(arg)

   Calls method 'm' from a class in the MRO (Method 
Resolution Order) of 'self'.  The selected class is the first 
one which is above 'cls' in the MRO and which 
contains 'm'.

The 'super' built-in function actually returns not a class, 
but a 'super' object.  This object can be saved, like a 
bound method, and later used to do a new search of the 
MRO for a different method to be applied to the saved 
instance.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=973579&group_id=5470



More information about the Python-bugs-list mailing list