[Python-Dev] Incorrect documentation of the raw_input built-in function

2008-01-24 Thread Mike Kent
Recently I was trying to debug an old python program who's maintenance I
inherited.  I was using the quick-and-dirty method of putting some 'print
>>sys.stderr' statements in the code, and then running the command with
'2>filename' appended to the end of the command line.  Imagine my surprise
to see that all of the prompt text from the program's raw_input calls were
also disappearing from the screen output, and appearing in the stderr
output routed to the file.

The latest documentation for raw_input states "If the prompt argument is
present, it is written to standard output without a trailing newline."
I posted a question regarding the observed behavior to comp.lang.python
and Gabriel Genellina (thanks Gabriel!) pointed out that despite the
documentation, raw_input was hard-coded to always output its prompt text
to stderr.

This raises two questions:
1. Shouldn't the current documentation be corrected to state that raw_input
writes its prompt to standard error?
2. Is this really the hard-coded behavior we want?  I don't think my
use-case is that odd; in fact, what I find very odd is that the prompt
output is send to stderr.  I mean, I'm printing the prompt for a question,
not some error message. Can there not at least be an optional parameter to
indicate that you want the output sent to stdout rather than stderr?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Incorrect documentation of the raw_input built-in function

2008-01-24 Thread Mike Kent
  pobox.com> writes:

> 
> 
> Isaac> Have people actually verified that the prompt is really sent to
> Isaac> stderr right now by using 2>/dev/null to attempt to suppress it?
> 
> Good point.  On my machine at work (Solaris), Python 2.4 seems to send its
> raw_input prompt to stdout, not stderr:
> 

> 
> Same for 2.6a0 on my Mac at home.  Mike, are you sure about it prompting to
> stderr?  If so, what's your setup?
> 
> Skip

Skip, Guido and others:

Interesting point about whether GNU readline is installed.  My setup is RedHat
Linux, with Python 2.5 that I built and installed myself.  GNU readline is not,
in fact, installed.  If you look at Python2.5/Parser/myreadline.c, function
PyOS_StdioReadline, line 125, you will see that prompt output is being sent to
stderr.  As best as my Python-fu can determine, this is the code used to output
a raw_input prompt (thanks again to Gabriel Genellina for pointing me in the
right direction.)

It's entirely likely that the difference in what I am seeing and what you guys
are seeing is caused by my not having GNU readline installed.  Nevertheless,
the behavior without it seems wrong, and is certainly different from the
documentation.


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Incorrect documentation of the raw_input built-in function

2008-01-24 Thread Mike Kent
Guido van Rossum  python.org> writes:

>
> > It's entirely likely that the difference in what I am seeing and what you
> > guys
> > are seeing is caused by my not having GNU readline installed.  Nevertheless,
> > the behavior without it seems wrong, and is certainly different from the
> > documentation.
> 
> Agreed.
> 

Being that Guido agrees, should I put a bug report into the system for it, and
if so, which should it report as the bug: the actual behavior of the raw_input
prompt when GNU readline is not installed, or the documentation?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com