← All notes

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

Sources

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

Permanent ID: iil:note:yvap5ntj

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.},
}

Markdown

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.

All artifact files (JSON index)

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.