Typing exit()
exits from Python command line. Typing exit
says:
Use exit() or Ctrl-Z plus Return to exit
When you type exit
, you want to exit. Why does the interpreter give me the above error when it knows I am trying to exit? Why doesn't it just exit?
In my python interpreter exit
is actually a string and not a function -- 'Use Ctrl-D (i.e. EOF) to exit.'
. You can check on your interpreter by entering type(exit)
In active python what is happening is that exit is a function. If you do not call the function it will print out the string representation of the object. This is the default behaviour for any object returned. It's just that the designers thought people might try to type exit to exit the interpreter, so they made the string representation of the exit function a helpful message. You can check this behaviour by typing str(exit)
or even print exit
.