> It's hard to see how they could. How would you *install* an import hook before __main__ got imported?

By doing crazy things like trying to reload __main__, or by deleting __main__ from the system modules and trying to re-import it, or by using introspection to load the file containing __main__ and stuffing it into sys.modules, or doing other nasty things.

It's hard to see how any of these would work. I just wanted to confirm "they don't".


On Sat, Nov 23, 2013 at 7:35 PM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Haoyi Li wrote:
Import hooks don't work with __main__ =( I spent a while trying to get it to work when working on MacroPy, to no avail.

It's hard to see how they could. How would you *install*
an import hook before __main__ got imported?

--
Greg

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