A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-August/047756.html below:

[Python-Dev] Could getpass use streams other than stdin?

[Python-Dev] Could getpass use streams other than stdin?Mike Brown mike at skew.org
Fri Aug 13 00:26:23 CEST 2004
On posix, it would be useful if I could have getpass.getpass() write the 
prompt to stderr or to an arbitrary stream (file-like object), rather than 
always writing to stdin.

In my use case, I need to send the results of a command-line script to stdout 
after the user authenticates, and the user may be redirecting stdout, so I 
don't want the password prompt to pollute the output. If I could have the 
"Password: " show up in stderr, that would be ideal.

I don't think this would be terribly difficult to implement an API like

def getpass(prompt='', stream=None)
    if stream is None:
        stream = sys.stdin
    ...

but I'm unsure of the nuances of termios and arbitrary streams. Would it be 
better to just make the choice be between stdin and stderr? -- in which case 
the API would be something like

def getpass(prompt='', use_stderr=False)

Or is the whole exercise a waste of time?

Thanks
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4