[Python-Dev] Re: Could getpass use streams other than stdin? (original) (raw)
Fredrik Lundh fredrik at pythonware.com
Fri Aug 13 08:29:58 CEST 2004
- Previous message: [Python-Dev] Could getpass use streams other than stdin?
- Next message: [Python-Dev] Unifying Long Integers and Integers: baseint
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Could getpass use streams other than stdin?
- Next message: [Python-Dev] Unifying Long Integers and Integers: baseint
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]