load_module for import entire package

Dave Angel davea at davea.name
Wed Dec 11 10:05:35 EST 2013


On Tue, 10 Dec 2013 23:28:31 -0800 (PST), Sergey <sh0375 at gmail.com> 
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 previously. 

That's how import works.  Once something has been imported,  the 
module information is cached. There are three ways to defeat that, 
but they're all risky. 



> How to replace line "from tmp import main" by getting properties of 
pkg?

No clue what you mean by that.

-- 
DaveA




More information about the Python-list mailing list