How to tell python to reload module whenever it sees import statement -


i'm writing program manage flow of processing data. user can write code of several method process data, called 'flow code', , tell program compare result of each method. code executed exec.

there's git repo containing functions call, , user can import them in 'flow code'.

my question is, because user can change repo between each execution, how tell python reload modules when sees import statement in 'flow code'? current solution that, before executing line, check type of local variable of 'flow code' , reload if type moduletype. however, inefficient. there better solution, hooks?

someone said imputil can make hooks, documentation says:

deprecated since version 2.6: imputil module has been removed in python 3.

and i'm using python 2.7

use reload method.

e.g.

>>> import test >>> test.a 1 >>> test.a = 3 >>> test.a 3 >>> reload(test) <module 'test' 'test.pyc'> >>> test.a 1 >>>  

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -