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>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4