a = super(Foo, self).getid() should be a = super(FooSon, self).getid()
On Tue, Mar 25, 2008 at 2:34 PM, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: > > Rather than use Foo.bar(), use this syntax to call methods of the > > super class: > > > > super(ParentClass, self).method() > > Hi Jeff, > here is the nw version which cause an error > > class Foo(object): > def __init__(self): > self.id = 1 > > def getid(self): > return self.id > > class FooSon(Foo): > def __init__(self): > Foo.__init__(self) > self.id = 2 > > def getid(self): > a = super(Foo, self).getid() > b = self.id > return '%d.%d' % (a,b) > > > FooSon().getid() > > > Traceback (most recent call last): > File "a.py", line 19, in <module> > FooSon().getid() > File "a.py", line 14, in getid > a = super(Foo, self).getid() > AttributeError: 'super' object has no attribute 'getid' > -- > http://mail.python.org/mailman/listinfo/python-list > -- Furkan Kuru
-- http://mail.python.org/mailman/listinfo/python-list