I’ve always thought this was a dumb idea. Apparently, the python gods noted that people would often try typing 'exit' to exit the interpreter. But, instead of allowing this, they added a toplevel string variable with a default value of "Use Ctrl-D (i.e. EOF) to exit.". So, if you type 'exit', that string gets evaluated, and subsequently printed by the interpreter.
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> exit
‘Use Ctrl-D (i.e. EOF) to exit.’
I guess that’s helpful, but you know what would be more helpful? Just exit the freaking program!
To me, this is like if your web browser had a “refresh” button that popped up a dialog telling you to press the “reload” button.
By the time you acknowledge your users’ expectations by adding code to your product, the only sane choice is to make your product do what your users are expecting. I bet whoever added it thought it was clever that the interpreter would print the string when it was evaluated, and “clever” won over “sensible.” Oh well.
That’s not even the worst part. The other bad thing about this hack, is that it only really works in the interpreter. If you mistakenly type 'exit' as part of a python program, this hack means you don’t get an error. Unfortunately, you don’t get a program exit, either. You just get a silently disregarded string value. I can imagine a poor entry-level coder trying to debug that problem! “It seems to be disregarding my exit statement!” meh… The poor user’s only hope is if they misspelled it, since 'exut' would raise a NameError (which would actually exit the program if it’s not caught).
Don’t get me wrong. I like python quite a bit (though I use it very little). This is just one of those things that’s always irked me.