__missing__ for the top-level Python script

Chris Angelico rosuav at gmail.com
Wed Nov 12 12:49:35 EST 2014


On Thu, Nov 13, 2014 at 1:56 AM, Skip Montanaro
<skip.montanaro at gmail.com> wrote:
> sys.excepthook = autoload_exc
>
> I can't see a lot of people wanting this (I normally have its import
> commented out in my PYTHONSTARTUP file), and I think it would probably
> be bad practice for new users of the language.

Interesting data point there - that you actually have it handy and
choose not to use it. It's clearly designed for interactive mode, as
it assumes that it can restart entire blocks of code:

>>> for x in (1,2,3):
...  print x
...  if x==2: print os.pathsep
...
1
2
autoloading os
1
2
:
3

But that's about as good a "now go try this again" as will ever be
achieved with sys.excepthook, I expect.

ChrisA



More information about the Python-list mailing list