Python Import Hooks and __main__ -
pep 302 defines way user code hook import process , intercept imports.
however, works imports occur after code has run register import hook.
almost definition, no code runs before __main__
module, script run. haven't had luck trying import hooks (which useful things) intercept code being loaded __main__
module.
is there way forward i'm missing, or out of luck? can accept having import hooks not perform transformations on __main__
module, nice if did.
have tried importing inside main this?
if __name__ == '__main__': import foo # rest of code here
Comments
Post a Comment