[Python-Dev] a quit that actually quits (original) (raw)

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Tue Dec 27 15:41:11 CET 2005


Fredrik Lundh wrote:

Reinhold Birkenfeld wrote:

What is wrong with something like this:

>>> class Quitter: ... def repr(self): raise SystemExit ... >>> exit = quit = Quitter()

vars() # oops!

You're right.

class Quitter: ... def repr(self): ... n = sys._getframe(1).f_code.co_names ... if n == ("exit",) or n == ("quit",): ... raise SystemExit

better? ;)

Reinhold

-- Mail address is perfectly valid!



More information about the Python-Dev mailing list