using super

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Jan 18 19:57:15 EST 2010


En Mon, 18 Jan 2010 16:50:45 -0300, Jean-Michel Pichavant  
<jeanmichel at sequans.com> escribió:
> Duncan Booth wrote:
>> Jean-Michel Pichavant <jeanmichel at sequans.com> wrote:
>>
>>
>>>>>> class SubClass(Base):
>>>>>>     colour = "Red"
>>>>>>     def parrot(self):
>>>>>>         """docstring for Subclass"""
>>>>>>         return super(Subclass, self).parrot()
>>>>>>
>>> I'm not a big fan of super, but I'm still wondering if

>>> return super(self.__class__, self).parrot()

>>> would have made it.
>>
>> No, it wouldn't. [...]
>>
> I see.
> Then is there a reason why
>   return super(Subclass, self).parrot()
> would be prefered over the "classic"
>   return Base.parrot(self)
> ?
> Or is it just a matter of preference ?

For a longer explanation, see:

James Knight: Python's Super Considered Harmful
http://fuhm.net/super-harmful/

Michele Simionato: Things to Know About Python Super
http://www.artima.com/weblogs/viewpost.jsp?thread=236275
http://www.artima.com/weblogs/viewpost.jsp?thread=236278
http://www.artima.com/weblogs/viewpost.jsp?thread=237121

-- 
Gabriel Genellina




More information about the Python-list mailing list