Newbie: module structure and import question
Ziong
ziongmail-py at yahoo.com
Wed Jan 12 10:06:43 EST 2005
hi all,
i have question on how to design a module structure.
for example, i have 3 files.
[somewhere]/main.py
[somewhere]/myLib/Base/BaseA.py
[somewhere]/myLib/ClassA.py
main.py
=======
from myLib.ClassA import ClassA
a = classA()
dir(a)
myLib/ClassA.py
===============
from myLib.Base.BaseA import BaseA
class ClassA(BaseA):
def __init__(self):
BaseA.__init__(self)
print "classA"
if (__name__ == "__main__"):
print "test class A"
a = ClassA()
print a
myLib/Base/BaseA.py
===================
class BaseA:
def __init__(self):
print "BaseA"
It's fine when i run main.py.
however when i run ClassA.py individually, it would fail in import
statment since the import path is incorrect.
I would like to know is something wrong in my design, or something i
missed.
Also, in practical usage, is that one class in one py file?
thx!
a python newbie
More information about the Python-list
mailing list