
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
rl
Advanced tools
The GNU Readline Library_ is the canonical implementation of command line
editing, tab completion, and history for console-based applications.
It is developed as part of Bash and available on virtually any platform.
While Python ships with readline bindings in its standard library, they only implement a subset of readline's features, just enough to perform identifier completion at the Python interpreter prompt.
The rl package aims to provide full implementations of GNU Readline's
Custom Completer_ and History_ interfaces.
It also contains high-level APIs to better organize the namespace and
shield applications from low-level verbosity.
.. _GNU Readline Library: https://tiswww.case.edu/php/chet/readline/rltop.html
.. _Custom Completer: https://tiswww.case.edu/php/chet/readline/readline.html#Custom-Completers
.. _History: https://tiswww.case.edu/php/chet/readline/history.html#History-Functions
rl exports these components:
completer Interface to the readline completer. Used to configure the completion aspects of readline.
completion Interface to the active readline completion. Used to interact with readline when a completion is in progress.
history Interface to the readline history. Used to read and write history files and to manipulate history entries.
readline The readline bindings module. Contains everything known from the standard library plus extensions specific to the rl package. The completer, completion, and history interfaces make use of this module, and you should rarely need to interact with it directly.
generator A decorator turning any callable into a completion entry function that can be handed to readline.
print_exc A decorator printing exceptions to stderr. Useful when writing Python completions and hooks, as exceptions occurring there are usually swallowed by the in-between C code.
For further details please refer to the API Documentation_.
.. _API Documentation: https://rl.readthedocs.io/en/stable/
rl development is hosted on GitHub_ where it also has an issue tracker_.
.. _GitHub: https://github.com/stefanholek/rl
.. _issue tracker: https://github.com/stefanholek/rl/issues
rl requires Python 2.7 or higher. The installer builds GNU Readline 8.2 and a Python extension module.
On Mac OS X make sure you have Xcode Tools installed. Open a Terminal window and type::
gcc --version
You either see some output (good) or an installer window pops up. Click
the "Install" button to install the command line developer tools.
A more detailed tutorial is available from the Mac Install Guide_.
.. _Mac Install Guide: https://mac.install.guide/commandlinetools/
On Linux and BSD systems you probably already have a C compiler, but you may need to verify the development environment is complete. For example, Ubuntu lacks the Python headers by default and Fedora is missing some compiler configuration. Lastly, readline needs a termcap library to link to.
Ubuntu/Debian::
sudo apt install build-essential
sudo apt install python3-dev
sudo apt install libncurses-dev
Redhat/Fedora::
sudo dnf install gcc
sudo dnf install python3-devel
sudo dnf install ncurses-devel
Then type::
pip install rl
kmd.Kmd_ is an rl-enabled version of cmd.Cmd_.
.. _kmd.Kmd: https://github.com/stefanholek/kmd
.. _cmd.Cmd: https://docs.python.org/3/library/cmd.html
Include fully-patched GNU Readline 8.2.13. [stefan]
Replace size_t with Py_ssize_t. [stefan]
Remove unnecessary function pointer casts. [stefan]
Do not rely on Python.h for standard headers. [stefan]
Update to Python 3.13 C-API. [stefan]
Update tox.ini for latest tox. [stefan]
Replace deprecated python setup.py build_sphinx in tox.ini.
[stefan]
Include GNU Readline 8.2. [stefan]
Improve documentation and example code. Promote using generator as a
decorator.
[stefan]
Document how directory_completion_hook interacts with new hooks added
in version 3.0.
[stefan]
Implement Python 3.6 readline.set_auto_history and the corresponding
history.auto.
[stefan]
Fall back to ncurses if termcap auto-detection fails. This at least produces a linker error instead of silently borking the extension. [stefan]
Replace deprecated python setup.py test in tox.ini.
[stefan]
Remove deprecated test_suite from setup.py.
[stefan]
Remove setuptools from install_requires.
[stefan]
Add a pyproject.toml file. [stefan]
Include tests in sdist but not in wheel. [stefan]
rl is now GPLv3 because it statically links to GNU Readline. [stefan]
Include GNU Readline 8.0. [stefan]
Support Python 3.6 os.PathLike objects for filenames. [stefan]
Handle new GIL checks in Python 3.6. See PYTHONMALLOC_.
[stefan]
Add history.max_file and history.append_file.
[stefan]
Add directory_rewrite_hook, filename_rewrite_hook, and
filename_stat_hook.
[stefan]
Catch up with bug fixes applied to the standard library readline module. [stefan]
Stop using 2to3. [stefan]
Remove reset APIs from the documentation. They override
~/.inputrc and should only be used in tests.
[stefan]
.. _PYTHONMALLOC: https://docs.python.org/3/whatsnew/3.6.html
Implement history iterators in C instead of relying on intermediate lists. [stefan]
Raise a more informative error when history slicing is attempted. [stefan]
Restore support for gcc < 4.2. [stefan]
Switch to a happier looking Sphinx theme. [stefan]
Force a static build if the RL_BUILD_STATIC_READLINE environment variable is set. [stefan]
Include readline 6.2 patches in static builds. [stefan]
Suppress compiler warnings on more platforms. [stefan]
Drop support for cmd.Cmd. You now must derive your command
interpreters from kmd.Kmd_ to use rl features.
[stefan]
Accept None as argument to file operations under Python 3. [stefan]
Switch to pretty Sphinx-based docs. [stefan]
read_history_file and write_history_file.
[stefan]get_y_or_n.
[stefan]get_y_or_n.
[stefan]Fix memory leaks in py_remove_history, py_replace_history, and
py_clear_history which can occur when history entries are edited.
See Python issue 12186_.
[stefan]
Add a default display_matches_hook that behaves exactly like readline
behaves in Bash.
[stefan]
Add reset functions to completer, completion, and history.
[stefan]
.. _issue 12186: https://bugs.python.org/issue12186
Add xfree.c to sources when building GNU Readline 6.2. [stefan]
Allow history indexes of type long. [stefan]
Use a custom build_ext command to find the best termcap library. [stefan]
Update static builds to GNU Readline 6.2. [stefan]
py_remove_history and py_replace_history.
See Python issue 9450_.
[stefan].. _issue 9450: https://bugs.python.org/issue9450
Update README, API documentation, and examples. [stefan]
MacPython detection caught other framework builds as well. [stefan]
Rework the history interface: Implement iteration and remove redundant APIs. [stefan]
History stifling could cause duplicate history entries. [stefan]
Make sure begidx and endidx completion variables are reset to 0.
[stefan]
Remove unused defines; we don't support libedit or readline < 5.0. [stefan]
Improve performance of get_current_history_length.
[stefan]
get_history_item zero-based and remove get_history_base.
[stefan]The history size can now be limited ("stifled") by setting
history.max_entries. This supersedes history.length which has been
removed.
[stefan]
Close a memory leak in get_current_history_length. Also see Python
issue 8065_.
[stefan]
.. _issue 8065: https://bugs.python.org/issue8065
PyGILState_Ensure in all
the right places. Fixes rl issue/5_. Removes the workaround introduced in
1.5.2.
[stefan]issue/5_.
[stefan].. _issue/5: https://github.com/stefanholek/rl/issues#issue/5
PEP 383_ for the low-down.
[stefan].. _PEP 383: https://www.python.org/dev/peps/pep-0383/
rl can now be installed into the system Python on Mac OS X, the only dependency being Xcode Tools. [stefan]
Change license to PSF or GPL. [stefan]
Fix header detection under Fink on Mac OS X. [stefan]
Add readline_version API.
[stefan]
Remove all occurrences of old-style function typedefs to silence compiler warnings. [stefan]
Make the display_matches_hook work in Python 2.5. Fixes rl issue/1_.
[stefan]
No longer auto-refresh the prompt at the end of display_match_list.
Applications should call redisplay(force=True) to restore the prompt.
[stefan]
.. _issue/1: https://github.com/stefanholek/rl/issues#issue/1
word_break_hook. Three cheers for Xcode's
leaks tool.
[stefan]Rename _readline module to readline since it's not private.
[stefan]
Remove dump and read_key APIs from public interfaces.
[stefan]
Unclutter the completer interface by removing settings that can
just as well be made with parse_and_bind.
[stefan]
Fix a memory leak in username_completion_function and
filename_completion_function.
[stefan]
Add a custom epydoc stylesheet to make its reST rendering more pleasant. [stefan]
Make all completion properties writable. While not useful in
production, this allows us to write better tests.
[stefan]
Improve API documentation and add a call graph for the completion process. This goes a long way in explaining how readline completion works. [stefan]
Implement the generator factory using an iterator instead of a list.
[stefan]
Remove find_completion_word so people don't get ideas.
[stefan]
Don't list distribute as dependency, setuptools will do the right thing. [stefan]
Add __slots__ to interface objects to make them immutable.
[stefan]
Support Python 2.5, 2.6, and 3.1 (thanks to distribute). [stefan]
Approach something like test coverage. [stefan]
Make the generator factory work for all types of callables.
[stefan]
Improve examples. [stefan]
FAQs
Alternative Python bindings for GNU Readline
We found that rl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.