Inheritance Confusion

Andy Todd atodd at spam.free.email.com
Wed May 2 19:22:05 EDT 2001


All,

<Obligatory grovel>
I apologise in advance for being a mere procedural programmer in the
wonderful world of oo, but I am confused. 
</Obligatory grovel>

My following script doesn't do what *I* expect it to, can someone please
help me by explaining why; 

--

class A:
    def __init__(self):
        self.x = "blah blah"

class B(A):
    def _init__(self):
        A.__init__(self)
        self.y = "boo boo"

>>> wibble=B()
>>> dir(wibble)
['x']

--

What happened to self.y that I assigned in the __init__ method of class
B? By observation I assume that the line - self.y = "boo boo" - is not
being executed, but no exceptions are raised. 

Maybe I'm missing the point or trying to use the wrong structure or
technique, if anyone can point me to decent web primers on this I'd be
very grateful. 

Regards,
Andy

-- 
"No matter what the weather, you and the clouds will still be beautiful"
Remove spam.free to email me



More information about the Python-list mailing list