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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -