Ka-Ping Yee wrote: > Fredrik's NameError-based proposal (exit when there's an exception > with no tb_next that says "name 'exit' is not defined") causes the > interpreter to quit when you enter any expression involving 'exit'. > > print exit # seems surprising > [3, 4, 5, exit] # seems surprising > 'a' in 'xyz' or exit # desirable or undesirable? > del exit # actually happened to me > x = exit # seems surprising
the easiest way to solve this that I can think of right now is to add a new sys variable that contains a copy of the most recent line read by the interactive prompt. if sys.commandline.strip() in ("exit", "quit"): sys.exit() </F> _______________________________________________ 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