Re: load_module for import entire package

2013-12-12 Thread Sergey
> This should work: > def get_obj(): > tmp = load_package_strict("tmp", basedir) > return tmp.main.TTT() Thank you:) I can only mention that it is working only if __init__.py of pkg contains line: import main To avoid modules caching I copy package to the new folder with anot

Re: load_module for import entire package

2013-12-11 Thread alex23
On 11/12/2013 5:28 PM, Sergey wrote: def get_obj(): pkg = load_package_strict("tmp", basedir) from tmp import main return main.TTT() It is working, but if package code changes on disc at runtime and I call get_obj again, it returns instance of class, loaded for the first time previous

Re: load_module for import entire package

2013-12-11 Thread Dave Angel
On Tue, 10 Dec 2013 23:28:31 -0800 (PST), Sergey wrote: def get_obj(): pkg = load_package_strict("tmp", basedir) from tmp import main return main.TTT() It is working, but if package code changes on disc at runtime and I call get_obj again, it returns instance of class, loaded for the

load_module for import entire package

2013-12-10 Thread Sergey
Hi, I need to import package and instantiate a class, defined in one of modules, located in package. Package is located in folder "tmp". basedir - path to running python script. I'm doing it so: import imp def load_package_strict(p_package_name, p_package_path): f, filename, description =