On Mar 25, 2:31 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
> I wish it was that simple but 'a = Foo().getid()' is actually creating
> a new instance of Foo whereas I want the data of the Foo instanced by
> __init__ of FooSon().

I don't think Foo.__init__(self) creates an instance of the Foo
class.  If you want FooSon to create an instance of Foo, try:

class FooSon(Foo):
    def __init__(self):
        self.foo = Foo()
        self.id = 2
    def getid(self):
        a = self.foo.getid()
        b = self.id
        return '%d.%d' % (a,b)

>>> FooSon().getid()
'1.2'

Or change "self.id" in Foo to something else, e.g., "self.id_foo".

Does that help?

Anthony
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to