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/047771.html below:

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

[Python-Dev] Re: Could getpass use streams other than stdin? [Python-Dev] Re: Could getpass use streams other than stdin?Fredrik Lundh fredrik at pythonware.com
Fri Aug 13 08:29:58 CEST 2004
Mike Brown wrote:

> 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.

you can redirect sys.stdin/sys.stdout before you call getpass:

    try:
        old_stdout = sys.stdout
        sys.stdout = sys.stderr
        password = getpass.getpass(prompt)
    finally:
        sys.stdout = old_stdout

</F> 



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