Inheritance Confusion
Robin Becker
robin at jessikat.fsnet.co.uk
Wed May 2 19:39:00 EDT 2001
In article <Xns90965FBC2B2A0atodddexterpinioncom at 203.2.194.51>, Andy
Todd <atodd at spam.free.email.com> writes
>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']
>
>--
>
strange, I see
PythonWin 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on
win32.Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com)
- see 'Help/About PythonWin' for further copyright information.
>>> class A:
... def __init__(self):
... self.x = 1
...
>>> class B(A):
... def __init__(self):
... A.__init__(self)
... self.y = 2
...
>>> b = B()>
>> dir(b)
['x', 'y']
>>>
--
Robin Becker
More information about the Python-list
mailing list