---
source: https://iinventedlight.com/library/notes/python-getpass.md
title: "getpass: prompt for a password without echoing"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-getpass"
tags: [python, getpass, password, cli]
client: Librarian
sources:
  - id: S1
    title: "getpass — Portable password input"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/getpass.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "getpass module documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/getpass.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# 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

- [python-logging-basics](https://iinventedlight.com/library/notes/python-logging-basics/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
