An inheritance question: getting the name of the "one up" class

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Mar 31 17:48:35 CEST 2009


En Tue, 31 Mar 2009 05:16:47 -0300, Steven D'Aprano  
<steven at remove.this.cybersource.com.au> escribió:

> On Tue, 31 Mar 2009 01:29:50 -0300, Gabriel Genellina wrote:
>
>>> Oh, and while the gurus are at it, what would be the advantage (if any)
>>> of changing, say
>>>    Primate.__init__(self)
>>> to
>>>     super(Human, self).__init__()
>>
>> None, if you use single inheritance everywhere.
>
> But there's no disadvantage to using super with single inheritance (and
> new-style classes).

It's ok *if* you follow the guidelines at the end of the "harmful"  
document.

>> super is very tricky; see:
>> http://fuhm.net/super-harmful/
>> and
>> http://www.artima.com/weblogs/viewpost.jsp?thread=236275
>
> As I understand it, the trickiness only comes about when you have diamond
> diagrams in your MRO.

With multiple inheritance, you *always* have a diamond diagram - every  
class inherits from object.

-- 
Gabriel Genellina




More information about the Python-list mailing list