Inheritance question

Tzury Bar Yochay Afro.Systems at gmail.com
Tue Mar 25 12:44:34 CET 2008


given two classes:

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 = Foo.getid()
        b = self.id
        return '%d.%d' % (a,b)

While my intention is to get 1.2 I get 2.2
I would like to know what would be the right way to yield the expected
results



More information about the Python-list mailing list