how to provide starting directory for __import__ function in python 2.7.6 -
i have class configured configs. has file structure:
-basemodel --model1 ---config --model2 ---config etc and inside model constructor read exact config depending input params __import__
i want add basemodel2(basemodel) inherited basemodel
and file structure change that
-basemodel -basemodel2 --basemodel2a ---config --basemodel2b ---config but problem when invoke basemodel2 constructor invokes basemodel constructor , __import__ function inside trying resolve config basemodel instead of basemodel2
so how directly specify start point __import__ function allow search in basemodel2 subdirs instead of basemodel's ?
code simple basemodel.py:
class basemodel(object): def __init__(): ... config = __import__(configname, locals(), globals(), [], -1) basemodel2.py:
class basemodel2(basemodel): def __init__(): super(basemodel2, self).__init__(); the problem __import__ method invoked inside super() context resolving files under basemodel directory, need make resolve under basemodel2
Comments
Post a Comment