[Python-Dev] quit() on the prompt
Nick Coghlan
ncoghlan at gmail.com
Tue Mar 7 23:36:48 CET 2006
Ian Bicking wrote:
> class Quitter(object):
> def __init__(self, name):
> self.name = name
> def __repr__(self):
> return 'Use %s() to exit' % self.name
> def __call__(self):
> raise SystemExit()
> quit = Quitter('quit')
> exit = Quitter('exit')
>
> This is not very magical, but I think is more helpful than the current
> behavior. It does not satisfy the "just do what I said" argument for
> not requiring the call (quit() not quit), but eh -- I guess it seemed
> like everything that didn't require a call had some scary corner case
> where the interpreter would abruptly exit.
>
It also nicely aligns with the way that license() and help() already work at
the interactive prompt.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list