while True: reply = input('Enter text') if reply == 'stop': break print(reply.upper())
The result was:
Enter text:Traceback (most recent call last): File "C:\PythonProjects\5.py", line 2, in <module> reply = input('Enter text:') EOFError: EOF when reading a line [Finished in 0.2s with exit code 1]
It is only in Sublime Text 2. I tried IDLE, tried command line, everything is perfect. Why should Subleme shout at me?
By the way, maybe you could also explain my what EOF may mean in such situation. Of course, I have read in the documentation, that if EOF is read from input, the appropriate error is raised. I would like to model this situation. Is input only about the keyboard? If yes, what combination of keys should I input to get EOF?
Thank you in advance.
This question is tagged with
~ Asked on 2012-09-22 21:02:53
I had the same problem. The problem with the Sublime Text's default console is that it does not support input.
To solve it, you have to install a package called SublimeREPL. SublimeREPL provides a Python interpreter which accepts input.
There is an article that explains the solution in detail.
~ Answered on 2013-03-14 18:49:33
EOF is a special out-of-band signal which means the end of input. It's not a character (though in the old DOS days, 0x1B acted like EOF), but rather a signal from the OS that the input has ended.
On Windows, you can "input" an EOF by pressing
Ctrl+Z at the command prompt. This signals the terminal to close the input stream, which presents an EOF to the running program. Note that on other OSes or terminal emulators, EOF is usually signalled using
As for your issue with Sublime Text 2, it seems that
stdin is not connected to the terminal when running a program within Sublime, and so consequently programs start off connected to an empty file (probably
/dev/null). See also Python 3.1 and Sublime Text 2 error.
~ Answered on 2012-09-23 01:15:41