Inheritance question
Tzury Bar Yochay
Afro.Systems at gmail.com
Tue Mar 25 08:34:17 EDT 2008
> 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'
More information about the Python-list
mailing list