[Python-Dev] Incorrect documentation of the raw_input built-in function (original) (raw)
Steve Holden steve at holdenweb.com
Mon Jan 28 20:17:50 CET 2008
- Previous message: [Python-Dev] Incorrect documentation of the raw_input built-in function
- Next message: [Python-Dev] Incorrect documentation of the raw_input built-in function
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
On Jan 28, 2008 12:35 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Isaac Morland wrote:
What about an option (maybe even a default) to send the prompt to stdin?
The Postgres command line interface psql appears to do this: $ psql 2>&1 >/dev/null Password: $ No, it's probably using the C stdlib routine getpass(). From the man page: The getpass() function displays a prompt to, and reads in a password from, /dev/tty. If this file is not accessible, getpass() displays the prompt on the standard error output and reads from the standard input. So it appears that the official Unix Way prefers using stderr over stdout for prompting, if using the std files for it at all. That's a dangerous generalization from just one example. I'd prefer it if you could unearth some POSIX or Linux base document saying this. While I couldn't locate such a document, it makes sense when you consider that if such a process is part of a pipeline you really don't want the prompts being handled as input by the downstream processes.
That's why mv and similar utilities prompt on standard error.
I'd be very surprised if you can find a UNIX or Linux shell, for example, that prompts on standard output.
Writing to stdin would be wrong, since it's usually read-only, even when connected to a terminal. Nowadays, it often is writable I've found, but we still shouldn't assume that. regards Steve
Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/
- Previous message: [Python-Dev] Incorrect documentation of the raw_input built-in function
- Next message: [Python-Dev] Incorrect documentation of the raw_input built-in function
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]