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 rhettinger
Recipients b9, docs@python, rhettinger
Date 2014-06-21.02:14:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403316855.8.0.180141866295.issue21814@psf.upfronthosting.co.za>
In-reply-to
Content
> Wouldn't it be more consistent for new-style classes,
> instead of calling "object.__setattr__(self, name, value)",
> to call "super(<ClassName>, self).__setattr__(name, value)"?

That's not always the right thing to do.  Calling object.__setattr__ gives a known, guaranteed behavior.   Using super however relies on an MRO calculation that may send the super call outside the inheritance tree to a methods that wasn't expecting to be called. 

Put another way, super was designed for cooperative multiple inheritance with implies an element of coordinated cooperation that isn't always present.

I think the current advice should stand.  We aren't advising people to always use super instead of calling a parent class method directly.  Part of the reason is that super can be much trickier that people expect.

Also, in Python 2.7 super() doesn't have the same magical but clean invocation it has in Python 3.  The two argument form isn't as elegant looking or as easy to get right.
History
Date User Action Args
2014-06-21 02:14:15rhettingersetrecipients: + rhettinger, docs@python, b9
2014-06-21 02:14:15rhettingersetmessageid: <1403316855.8.0.180141866295.issue21814@psf.upfronthosting.co.za>
2014-06-21 02:14:15rhettingerlinkissue21814 messages
2014-06-21 02:14:15rhettingercreate