getpass: prompt for a password without echoing
Answer: getpass() prompts the user for a password without echoing. The default prompt is 'Password: '. The echo_char argument controls how user input is displayed while typing.
The prompt
Two functions ship in the getpass module.
The getpass function prompts the user for a password, and it does so without echoing.
The user is prompted using the string prompt, which defaults to 'Password: '.
echo_char and fallbacks
Leave echo_char as None and the typed input remains hidden.
A non-None echo_char must be a single printable ASCII character; each typed character is then replaced by it.
When echo-free input is unavailable, getpass() falls back to printing a warning message.
See also
Claims
- id: C1 claim: getpass prompts the user for a password without echoing. source: S1 evidence: "Prompt the user for a password without echoing"
- id: C2 claim: The default prompt string is 'Password: '. source: S1 evidence: "defaults to 'Password: '"
- id: C3 claim: The module provides two functions. source: S2 evidence: "module provides two functions"
- id: C4 claim: The source docs also default the prompt to 'Password: '. source: S2 evidence: "defaults to `
'Password: '`"
Sources
- [S1] getpass — Portable password input. Python Software Foundation. https://docs.python.org/3/library/getpass.html . License: PSF License Version 2. Accessed 2026-11-23.
- [S2] getpass module documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/getpass.rst . License: PSF License Version 2. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, getpass — Portable password input; CPython, getpass module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, getpass — Portable password input; CPython, getpass module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "getpass: prompt for a password without echoing." iinventedlight Library, iil:note:yvap5ntj, version of 2026-11-23. https://iinventedlight.com/library/notes/python-getpass/. License: CC-BY-4.0.
@misc{iil_note_yvap5ntj,
author = {{iinventedlight}},
title = {{getpass: prompt for a password without echoing}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/python-getpass/},
note = {Permanent ID iil:note:yvap5ntj. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-getpass.schema.json (schema; CC-BY-4.0)
- python-getpass.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-getpass.md.