On Jan 26, 7:23 am, Dox33 <[EMAIL PROTECTED]> wrote: > I ran into a very strange behaviour of raw_input(). > I hope somebody can tell me how to fix this. ===CUT=== > *** Thirst, redirect stderr to file, STRANGE behaviour...... > From the command prompt I run: > python script.py 2> stderr_catch.txt > This should redirect strerr to the file and stdout should stay on the > screen. > > But..... What happens? > After a few 'enter' keys, on screen apears: > 1: This is the print statement. > 3: This is a possible solution. > > WHERE IS THE SECOND LINE? > It is in the file stderr_catch.txt!!! > > **** See the problem? > Please Tell me? Why is the prompt produced by raw_input() printed to > the error channel? It should be stdout, just as the print statement > does.
I recently ran into this behaviour myself, and reported it both here and to the python-dev mailing list. See http://groups.google.com/group/comp.lang.python/browse_thread/thread/1011238ac6b79292/6f8b7c47873a4a1e?lnk=gst&q=unexpected+behavior#6f8b7c47873a4a1e It turns out that *if* you don't have GNU readline installed, Python falls back to its own implementation of readline, which is hard-coded to send the prompt output to stderr. Guido agreed that this is wrong, and a bug for it has been entered into the Python bug tracking database. Your workaround until this bug is fixed is to install GNU readline, and rebuild your python installation to use it rather than the fall- back version. -- http://mail.python.org/mailman/listinfo/python-list