On 16Jan2022 20:57, MRAB <python@mrabarnett.plus.com> wrote:
There was a discussion on another forum that mentioned the 'input' function, and it made me wonder whether 'input' should be printing the prompt to stderr instead of stdout.
The convention is for normal output to go to stdout and error messages to go to stderr, so if a program needs to ask the user, shouldn't it be using stderr for prompts in order not to mess up the normal output?
This is a good reason to avoid sending prompts to stdout. But stderr isn't necessarily right either. If stderr's attached to a tty (UNIX, different techiness for Windows) you could reasonably send to stderr, otherwise you might be better opening /dev/tty (if you're allowed to, and if you have one). Etc etc. There was a long thread in the "Core Development" forum just the other day about this, here: https://discuss.python.org/t/builtin-function-input-writes-its-prompt-to-sys... Have a read. Cheers, Cameron Simpson <cs@cskk.id.au>