Newbie inheritance question.

Christophe Cavalaria chris.cavalaria at free.fr
Sun Jan 16 09:25:57 EST 2005


bwobbones wrote:

> Hi all,
> 
>   I'm a java programmer struggling to come to terms with python - bear
> with me!
> 
>   I'm trying to subclass a class, and I want to be able to see it's
> attributes also.  Here are my classes:
> 
> two.py
> *****************************
> from one import one
> 
> class two(one):
>     def __init__(self):
>         print "two"
> 
>     def printTestVar(self):
>         print "testVar: " + str(self.testVar)
> *****************************

You simply forgot to call the parent __init__. You have to do that
explicitely in Python.



More information about the Python-list mailing list