On 3/8/06, Brett Cannon <[EMAIL PROTECTED]> wrote:
On 3/7/06, Ian Bicking <[EMAIL PROTECTED]> 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')

+1 from me.  Only change I would make is pass an argument to
SystemExit() such as "%s() called", although the chances of this
exception being caught is very slim.

Raising SystemExit("quit() called") has an additional benefit (although the wording could use some work):
 
>>> raise SystemExit("quit() called")
quit() called

(At least, I consider that a benefit :-)
--
Thomas Wouters <[EMAIL PROTECTED]>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________
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