Nov. 24, 2013
12:37 a.m.
On Sun, Nov 24, 2013 at 09:04:59AM +1100, Chris Angelico wrote:
Just a really crazy idea... Does Python let you go "one level outside" and tinker with the code that imports __main__? I haven't looked into all that mechanism, but I know quite a bit of it is now implemented in Python, so it's theoretically possible... could you, in effect, add a line of code *after* that import that effectively calls __main__.__main__(sys.argv) ? That would do most of what you want.
It sounds like you're describing an import hook, although such things are completely opaque to me. I know they exist, but I've got no idea how they work or what they can do. -- Steven