[Python-Dev] a quit that actually quits
Christopher Armstrong
radeex at gmail.com
Tue Dec 27 14:55:27 CET 2005
On 12/28/05, Reinhold Birkenfeld <reinhold-birkenfeld-nospam at wolke7.net> wrote:
> Fredrik Lundh wrote:
> > sourceforge just went off the air, so I'm posting this patch here, in order
> > to distract you all from Christian's deque thread.
> >
> > this silly little patch changes the behaviour of the interpreter so that "quit"
> > and "exit" actually exits the interpreter. it does this by installing a custom
> > excepthook that looks for NameErrors at the top level, in interactive mode
> > only.
>
> What is wrong with something like this:
>
> >>> class Quitter:
> ... def __repr__(self): raise SystemExit
> ...
> >>> exit = quit = Quitter()
>
> It could optionally check for top level too, of course.
Not sure if this is what you mean by "check for top level too", but
the obvious problem is that calling vars(__builtins__) (or similar)
will cause your interpreter to exit. :)
--
Twisted | Christopher Armstrong: International Man of Twistery
Radix | -- http://radix.twistedmatrix.com
| Release Manager, Twisted Project
\\\V/// | -- http://twistedmatrix.com
|o O| |
w----v----w-+
More information about the Python-Dev
mailing list