classification
Title: input function outputs prompt to stderr
Type: Stage:
Components: Versions: Python 3.6, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Change input() to always prompt to stderr
View: 1927
Assigned To: Nosy List: jaraco, martin.panter
Priority: normal Keywords:

Created on 2015-11-21 22:01 by jaraco, last changed 2015-11-21 23:09 by martin.panter. This issue is now closed.

Messages (2)
msg255072 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2015-11-21 22:01
The built-in function 'input' appears to be sending the prompt to stderr instead of stdout, as the docs state it should.

$ python3.5 -c "print('stdout'); import sys; print('stderr', file=sys.stderr); input('foo')" 2> errors.txt
stdout
hello
$ cat errors.txt
stderr
foo

I've replicated this behavior in both Python 3.4 on Linux and Python 3.5 and 2.7 on OS X. Here's the 2.7 test/output:

$ python2.7 -c "from __future__ import print_function; print('stdout'); import sys; print('stderr', file=sys.stderr); raw_input('foo')" 2> errors.txt
stdout
hello
$ cat errors.txt 
stderr
foo

I believe the stated behavior (outputting the prompt to stdout) is the proper behavior.

I figure I must be doing something wrong here, because it seems bizarre to me that this discrepancy hasn't been discovered before.
msg255076 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-21 23:09
This has been discovered before: Issue 1927, with a simple patch. The choice between stdout and stderr seems to be rather complicated, so the patch may need a bit more work.
History
Date User Action Args
2015-11-21 23:09:28martin.pantersetstatus: open -> closed

nosy: + martin.panter
messages: + msg255076

superseder: Change input() to always prompt to stderr
resolution: duplicate
2015-11-21 22:01:43jaracocreate