[Python-ideas] Python hook just before NameError

Chris Angelico rosuav at gmail.com
Mon Dec 29 14:02:32 CET 2014


On Mon, Dec 29, 2014 at 11:46 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> However, even today, it's not particularly difficult to create custom launch
> scripts that initialise __main__ with a few different modules based on what
> you plan to work on and then set os.environ["PYTHONINSPECT"] = "1" to drop
> into the interactive interpreter:
>
> $ python3 -c "import sys, os; os.environ['PYTHONINSPECT'] = '1'"
>>>> sys, os
> (<module 'sys' (built-in)>, <module 'os' from '/usr/lib64/python3.4/os.py'>)
>>>>

Once again, that's fine for sys and os, which won't take long to
import. For this to work with _every_ module on the system, you'd need
to couple it with a lazy import mechanism. We had some proposals along
those lines recently... what happened to them?

ChrisA


More information about the Python-ideas mailing list