super question

Aahz aahz at pythoncraft.com
Tue Apr 8 15:24:35 CEST 2003


In article <Qdpka.2889$Zu2.2627 at news01.roc.ny.frontiernet.net>,
Lee Harr  <missive at hotmail.com> wrote:
>In article <b6soav$7p2$1 at panix1.panix.com>, Aahz wrote:
>> 
>>     class b(object):
>>         pass
>
>From the super docs ;o)  it says you might do this:
>
>    class C(B):
>        def meth(self, arg):
>            super(C, self).meth(arg)
>
>but why not just do:
>
>    class C(B):
>        def meth(self, arg):
>            B.meth(self, arg)
>
>Is there any difference?
>Any advantage either way?

The advantage comes when you rename B or when you have multiple base
classes for C.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

This is Python.  We don't care much about theory, except where it intersects 
with useful practice.  --Aahz, c.l.py, 2/4/2002




More information about the Python-list mailing list