|
⇤ ← Revision 1 as of 2023-04-25 02:02:08
Size: 496
Comment:
|
Size: 1158
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 17: | Line 17: |
| Get user input without printing to the screen. {{{ import getpass passwd = getpass.getpass(prompt='This is a prompt for your password: ') }}} The `prompt` anmed option defaults to `"Password: "`. Internally the prompt is written to a file stream (`/dev/tty` by default, or `sys.stderr` if that is unavailable). This can be configured with the `stream` named option ''except on [[Windows]]''. If a non-printing stream cannot be located, `getpass.getpass` falls back on `sys.stdin` and raises `getpass.GetPassWarning`. |
|
| Line 31: | Line 45: |
| Returns the value of the first non-empty environment variable: `LOGNAME`, `USER`, `LNAME`, and `USERNAME`, in that order. |
Python GetPass
getpass is a utility module for getting user input without printing to the screen.
Contents
Usage
GetPass
Get user input without printing to the screen.
import getpass passwd = getpass.getpass(prompt='This is a prompt for your password: ')
The prompt anmed option defaults to "Password: ".
Internally the prompt is written to a file stream (/dev/tty by default, or sys.stderr if that is unavailable). This can be configured with the stream named option except on Windows.
If a non-printing stream cannot be located, getpass.getpass falls back on sys.stdin and raises getpass.GetPassWarning.
GetPassWarning
A UserWarning subclass that is raised when user input may be printed to the screen.
GetUser
Returns the value of the first non-empty environment variable: LOGNAME, USER, LNAME, and USERNAME, in that order.
See also
Python getpass module documentation
