py files includings each others
Nicolas Bouillon
bouil at bouil.org.invalid
Tue Mar 23 19:42:23 EST 2004
Hi
I have a big problem while including file.
I have more that twenty classes, with one py file per class (more clear
& clean), and the following test case illustrate well my problem. I
facts, files including each other before the name of the classes seems
to be defined, so python fails...
Can you help me to resolve that ?
a.py:
====
from b import Man
class Person:
def __init__(self):
pass
def set_father(self):
self.father = Father()
====
b.py
====
from a import Person
class Father(Person):
def __init__(self):
Person.__init__(self)
p = Father()
====
Runing:
====
bouil at lisa:/tmp$ python b.py
Traceback (most recent call last):
File "b.py", line 1, in ?
from a import Person
File "/tmp/a.py", line 1, in ?
from b import Man
File "/tmp/b.py", line 1, in ?
from a import Person
ImportError: cannot import name Person
bouil at lisa:/tmp$
====
Thanks you.
More information about the Python-list
mailing list