我的问题似乎相当基本,但我似乎无法在任何地方找到任何帮助。
file_a.py >>
from xyz import XYZ
class A:
.
.
.
file_b.py >>
import file_a
from file_a import A
class B(A):
def __init__(self):
A.__init__(self)
def someMethod(self):
XYZ.doSomething()
XYZ.doSomething() fails saying NameError: name XYZ is not defined Even standard imports like import sys done from file_a does not seem to render it usable in file_b. I assumed that should work. Is my understanding wrong? If yes, then is there a way to have common imports and global variables across files? (If it is of nay help, I ve been a C++ and java programmer and am now starting to use python. )