Import hooks don't work with __main__ =( I spent a while trying to get it to work when working on MacroPy, to no avail. 


On Sat, Nov 23, 2013 at 4:37 PM, Steven D'Aprano <steve@pearwood.info> wrote:
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

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas