exiting Python

Peter Maas fpetermaas at netscape.net
Thu Mar 4 12:36:58 EST 2004


beliavsky at aol.com schrieb:
> I think exiting Python with 'Ctrl-Z plus Return' is awkward. Why not
> something simpler like ':q[uit]'. Since ':q' is currently invalid
> syntax, I don't think using it to quit Python would break anything.

class SimpleExit:
      def __repr__(self):
          print "Python: Sssssssee you!"
          import sys
          sys.exit(0)

q = SimpleExit()

Include this in your PYTHONSTARTUP and you're done. Just type

 >>> q

whenever you want to exit and avoid conflicting use of q in
interactive sessions. :-)

Mit freundlichen Gruessen,

Peter Maas

-- 
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail peter.maas at mplusr.de
-------------------------------------------------------------------



More information about the Python-list mailing list