[Python-ideas] python3: subtle change to new input()

Christian Heimes lists at cheimes.de
Wed Nov 14 16:57:46 CET 2007


Georg Brandl wrote:
> Mark Summerfield schrieb:
>> Hi,
>>
>> In Python 3, input() returns an empty string in two situations: blank
>> lines and EOF.
> 
> Could this be a platform issue? Here, on Linux, input() raises EOFError
> on EOF.

I think it's more likely a subtle difference between platforms:

On Linux
>>> r = input() <CTRL+D>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
EOFError
>>> r = input() <CTRL+Z>
[1]+  Stopped                 ./python
$ fg 1
./python
>>>

On Windows
>>> r = input() <CTRL+D>
^D <ENTER>
>>> r
'\x04'
>>> r = input() <CTRL+Z>
^Z <ENTER>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
EOFError

Christian




More information about the Python-ideas mailing list