On this page
getpass.getpass
Up: getpass | Next: getpass.GetPassWarning
Rel: getpass.GetPassWarning, getpass.getuser
Ref: docs.python.org — getpass.getpass
Tags: #public #python3 #stdlib #getpass
Import
import getpass
from getpass import getpass
Signature & Overview
getpass.getpass(prompt='Password: ', stream=None, *, echo_char=None)
Prompt for a password, with echo turned off.
Usage
import getpass
# Prompts for a secret without echoing characters to the terminal:
# secret = getpass.getpass("API token: ")
assert callable(getpass.getpass)
Gotchas
- Avoid in non-TTY / IDE runners without a terminal: Falls back to
sys.stdinwith echo on and emitsGetPassWarning.
REPL Inspect
from getpass import getpass
help(getpass)
Linked from
Related notes
- tuts/python3/stdlib_module/getpass/GetPassWarning Linked here; links to this page; shared tags: #getpass, #stdlib
- tuts/python3/stdlib_module/getpass/getuser Linked here; links to this page; shared tags: #getpass, #stdlib
- tuts/python3/stdlib_module/getpass links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib