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 stutzbach
Recipients LambertDW, georg.brandl, rhettinger, stutzbach
Date 2009-02-16.23:13:33
SpamBayes Score 2.171276e-06
Marked as misclassified No
Message-id <1234826081.47.0.298415753972.issue5229@psf.upfronthosting.co.za>
In-reply-to
Content
The new text is still inaccurate.  It reads in part "Return a proxy
object that delegates method calls to a parent class of type".  However,
this is not necessarily true.  Consider the following example of
diamond-inheritance, where we have a common Ancestor class that has two
children (Sibling1 and Sibling2), and a class that inherits from both
siblings (Child).

Child's call to super() returns a proxy for Sibling1's methods, as
described.  However, Sibling1's call to super() returns a proxy for
Sibling2's methods, even though Sibling2 is not Sibling1's parent.

Perhaps add some text stating something to the effect of:  If
object-or-type is an object returned by a previous call to super(), a
new proxy is returned for the next class in the hierarchy.  By
repeatedly calling super(), all the classes in the hierarchy can be
accessed.  Since a parent class's methods will often be accessed by a
proxy object, calling super() in a parent class will result in a proxy
for the next class in the object's class hierarchy which may have no
direct relationship to the parent class itself.

(Undoubtedly, it could be worded better, though)

>>> class Ancestor(object):
...   def foo(self):
...      print 'Ancestor.foo'
...
>>> class Sibling1(Ancestor):
...   def foo(self):
...     super(Sibling1, self).foo()
...     print 'Sibling1.foo'
...
>>> class Sibling2(Ancestor):
...   def foo(self):
...     super(Sibling2, self).foo()
...     print 'Sibling2.foo'
...
>>> class Child(Sibling1,Sibling2):
...   def foo(self):
...     super(Child, self).foo()
...     print 'Child.foo'
...
>>> x = Child()
>>> x.foo()
Ancestor.foo
Sibling2.foo
Sibling1.foo
Child.foo
History
Date User Action Args
2009-02-16 23:14:41stutzbachsetrecipients: + stutzbach, georg.brandl, rhettinger, LambertDW
2009-02-16 23:14:41stutzbachsetmessageid: <1234826081.47.0.298415753972.issue5229@psf.upfronthosting.co.za>
2009-02-16 23:13:34stutzbachlinkissue5229 messages
2009-02-16 23:13:33stutzbachcreate