raw_input - why doesn't prompt go to stderr

Terry Reedy tjreedy at udel.edu
Mon Jan 26 16:55:06 EST 2004


"Helmut Jarausch" <jarausch-remove at igpm.rwth-aachen.de> wrote in message
news:bv2smu$leh$1 at nets3.rz.RWTH-Aachen.DE...

> when using an interactive Python script, I'd like the prompt given by
> raw_input to go to stderr since stdout is redirected to a file.

This is not the usual behavior, so I presume that you or the code author
(if not the same) have done some non-standard redirection.

> How can I change this

If you wrote or have access to the code, write your own (two-line?) version
of raw_input(prompt) using stderror.write(prompt) and return stdin.read().

Or leave stdout alone and use print >> ofile or ofile.write() for the other
stuff.  Ofile can easily be selectable as either stdout or something else.

If you don't have the source, make suggestions to the owner/author.

> (and suggest making this the default behaviour)

You just did, but part of the definition of 'interactive' is stdout to the
screen or other humanly immediately readable output device ;-)

Terry J. Reedy







More information about the Python-list mailing list