← All notes

Python readline: configure GNU readline or libedit at the prompt

Answer: The readline module provides a GNU readline interface, and settings made using this module affect the interactive prompt and the prompts offered by the built-in input() function.

Where it is available and which library it wraps

You can use this module directly, or go through rlcompleter, which supports completion of Python identifiers at the interactive prompt.

Changes made here affect both the interpreter prompt and the prompts from the built-in input() function.

Keybindings usually come from an initialization file, typically .inputrc in the home directory.

The GNU Readline manual documents the format of that file and the library's features.

The module is not available on Android, iOS, or WASI, and it is not supported on mobile or WebAssembly platforms.

The underlying API may be implemented by editline (libedit) instead of GNU readline.

On macOS the module detects at run time which library is in use.

editline uses a different configuration file, named .editrc in the home directory when you use that emulation on macOS.

The backend attribute is "readline" or "editline", which helps when you load configuration strings in code.

Init file helpers

parse_and_bind(string) runs one init line and calls rl_parse_and_bind() in the underlying library.

read_init_file([filename]) runs a readline initialization file.

The default filename is the last filename used.

That helper calls rl_read_init_file() in the underlying library.

It raises an open auditing event with the given file name, or "<readline_init_file>" if none was given, regardless of which file the library actually opens.

The auditing event was added in version 3.14.

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, readline — GNU readline interface; CPython, readline 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, readline — GNU readline interface; CPython, readline documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:meefd039

iinventedlight. 2026. "Python readline: configure GNU readline or libedit at the prompt." iinventedlight Library, iil:note:meefd039, version of 2026-11-26. https://iinventedlight.com/library/notes/python-readline/. License: CC-BY-4.0.

@misc{iil_note_meefd039,
  author = {{iinventedlight}},
  title = {{Python readline: configure GNU readline or libedit at the prompt}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/python-readline/},
  note = {Permanent ID iil:note:meefd039. 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-readline.md.