あるファイルに親クラスがあり、別のファイルに子クラスがあり、それらを 3 番目のファイルで使用しようとしています。このような並べ替え:
test1.py
class Parent(object):
def spam(self):
print "something"
test2.py
class Child(Parent):
def eggs(self):
print "something else"
test3.py
from test1 import *
from test2 import *
test = Child()
test3.py を実行すると、次のようになります。
File "[path]\test2.py", line 1, in <module>
class Child(Parent):
NameError: name 'Parent' is not defined
親クラスと子クラスをすべて同じ場所に保持する必要がありますか?