I want to be able to reference a top level module inside another module (one level deeper). My solution works, but I want to know if this is the best way to do it. Please suggest for minimum python 2.4
In below example I want to import base.py
in abc.py
.
Here is a simplified directory structure -
- test.py
- mymodule/
- base.py
- __init__.py
- meta/
- abc.py
- __init__.py
Contents of base.py
class basec1:
def basec1f1(self):
print "base::C1::F1() called"
class basec2:
def basec2f1(self):
print "base::C2::F1() called"
Contents of abc.py
from mymodule.base import basec1
def abcfn():
print "abcfn() called"
obj = basec1()
obj.basec1f1()
Contents of test.py
import mymodule.meta.abc as abc
abc.abcfn()