Python Import Hooks and __main__

Sven R. Kunze srkunze at mail.de
Mon Aug 17 18:26:33 EDT 2015


Hi,

following up on this thread on StackOverflow 
http://stackoverflow.com/questions/16515347/python-import-hooks-and-main 
does somebody has a great idea how to manage this?

The issue at hand is, that I would like to apply a specific import hook 
right from the beginning of the interpreter run (here, a simple test 
case), i.e. also affecting the import/exec of the module __main__.

Hook: https://github.com/srkunze/fork/blob/2e7ecd4b0a/fork.py#L429
Dirty Magic to get things running: 
https://github.com/srkunze/fork/blob/2e7ecd4b0a/fork.py#L425

Best,
Sven



More information about the Python-list mailing list