Classes question
Aahz
aahz at pythoncraft.com
Thu Oct 31 16:08:33 EST 2002
In article <20021031205456.GA8006 at ens-lyon.fr>,
Emmanuel Jeandel <E_Jeandel at mail.dotcom.fr> wrote:
>
>I have the following code :
>
>class A:
> def __init__(self):
> pass
>
> def f(self):
> self.x = B()
>
>class B(A):
> def __init__(self):
> A.__init__(self)
>
>
>I would like to have the class A and the class B in two differents files.
>Is it possible ?
>I think that it is not directly possible, but if there is a mean with a
>small change in the code...
Assuming you put the code for A in classA.py, you can make class B work
by adding the line
from classA import A
before the "class B" statement.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Project Vote Smart: http://www.vote-smart.org/
More information about the Python-list
mailing list