Printing with raw_input

Peter Otten __peter__ at web.de
Tue Feb 16 03:55:50 EST 2010


Shashwat Anand wrote:

> raw_input uses sys.stderr I guess ?

I had a look at the C code, but it's a bit confusing.

If I'm reading it correctly the prompt is written to the "real" stderr if 
and only if sys.stdin and sys.stdout are attached to a terminal.

$ python -c"raw_input('prompt\n')" 2>tmp.txt
foo
$ cat tmp.txt
prompt
$ python -c"raw_input('prompt\n')" 2>tmp.txt | cat
foo
prompt
$ cat tmp.txt

I wonder if that is intentional.

Peter





More information about the Python-list mailing list