On Mar 25, 4:37 pm, Brian Lane <[EMAIL PROTECTED]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > > Gerard Flanagan wrote: > > Use the child class when calling super: > > > -------------------------------------- > > 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(FooSon, self).getid() > > b = self.id > > return '%d.%d' % (a,b) > > > print FooSon().getid() > > -------------------------------------- > > That still doesn't do what he's trying to do. >
Ah, I see. Maybe something like the following then? -------------------------------------- class Foo(object): def __init__(self): self._id = [1] def getid(self): return '.'.join(str(i) for i in self._id) class FooSon(Foo): def __init__(self): Foo.__init__(self) self._id.append(2) print FooSon().getid() -------------------------------------- G. -- http://mail.python.org/mailman/listinfo/python-list