10/23/26Less than 1 minuteAbout 122 words
Concept: The getpass module
| Function | Description | Example |
|---|---|---|
| getpass.getpass(prompt="Password: ") | Asks for input without echoing it to the terminal; use it for passwords, PINs and API keys. | pwd = getpass.getpass("SSH password: ") |
| getpass.getpass(prompt, echo_char="*") | Shows a character for each typed key instead of nothing (Python 3.14+). | pwd = getpass.getpass("Password: ", echo_char="*") |
| getpass.getuser() | Returns the login name of the current user (checks LOGNAME, USER, LNAME and USERNAME first). | getpass.getuser() → 'sebastiaan' |
| getpass.GetPassWarning | Warning raised when input can't be hidden, for example in some IDE consoles. | except getpass.GetPassWarning: |