[Tutor] Class - superclass
Bernard Lebel
3dbernard at gmail.com
Fri Apr 8 21:05:13 CEST 2005
Hello,
I'm experimenting with basic inheritance concepts, and something that
I would assume to work returns an error.
>>> class A:
... def __init__( self ):
... self.a = 13
...
>>> class B( A ): # create sub-class of class A
... def __init__( self ):
... self.b = 14
...
>>>
>>>
>>>
>>> b = B() # create instance of class B
>>> b.a # here I would expect the class A's a attibute to be accessible...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: B instance has no attribute 'a'
Anyone can shed any light on this? Using Python 2.3.4.
Thanks
Bernard
More information about the Tutor
mailing list