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!

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to