Gripe: Use Ctrl-D (i.e. EOF) to exit

jepler80 at unpythonic.net jepler80 at unpythonic.net
Mon Feb 23 15:48:04 EST 2004


Here's another workaround (also in ~/.pythonrc):
	class Exiter:
	    def __repr__(self): raise SystemExit
	quit = exit = Exiter()

$ python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11) 
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
$ 

Of course, *anything* that would print the repr of exit exits:
>>> globals()
$

This cure is worse than the disease, I think....

Jeff
PS I would never have considered making ^D do anything but send EOF in the
Python shell!  Even though I'm an avid vim user, I don't think I use ^D as
a motion in that program...




More information about the Python-list mailing list