Skip to main content

Introduction

The rl package aims to provide a full implementation of the GNU Readline Custom Completer interface.

Package Contents

rl exports the following 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.

generator

A factory 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.

history

Interface to the readline history. Used to read and write history files and to manipulate history entries.

readline

The readline interface 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.

For further details, please refer to the API Documentation.

Example Code

The code below implements system command completion similar to bash:

import os
from rl import completer
from rl import generator

def complete(text):
    # Return executables matching 'text'
    for dir in os.environ.get('PATH').split(':'):
        dir = os.path.expanduser(dir)
        if os.path.isdir(dir):
            for name in os.listdir(dir):
                if name.startswith(text):
                    if os.access(os.path.join(dir, name), os.R_OK|os.X_OK):
                        yield name

def main():
    # Set the completion function
    completer.completer = generator(complete)

    # Enable TAB completion
    completer.parse_and_bind('tab: complete')

    command = raw_input('command: ')
    print 'You typed:', command

More elaborate examples can be found here and in the gpgkeys package.

Repository Access

rl development is hosted on github.

Installation

rl has been tested with GNU Readline versions 5 and 6.

On Linux, install libreadline5-dev (or equivalent) before attempting to build rl. On Mac OS X, you need a Python built with MacPorts or Fink, as the system Python is linked to the BSD editline library and not GNU readline.

rl requires distribute >= 0.6.8. If you have not upgraded your setuptools yet, type:

/path/to/easy_install distribute

Then type:

/path/to/easy_install rl

and watch the console. When it reads:

Finished processing dependencies for rl

you are done and rl is ready to use.

Changelog

1.3 - 2010-01-03

  • Fix header detection under Fink on Mac OS X. [stefan]

  • Add readline_version API. [stefan]

1.2 - 2009-11-24

  • Improve API documentation and examples. [stefan]

1.1 - 2009-11-16

  • 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]

1.0 - 2009-11-08

  • No changes since 1.0a8.

1.0a8 - 2009-11-07

  • Close a memory leak in word_break_hook. Three cheers for XCode’s leaks tool. [stefan]

1.0a7 - 2009-11-05

  • Rename _readline module to readline since it’s not private. [stefan]

  • Remove dump and read_key APIs from public interfaces. [stefan]

1.0a6 - 2009-10-30

  • 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]

1.0a5 - 2009-10-29

  • 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]

1.0a4 - 2009-10-27

  • 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]

1.0a3 - 2009-10-22

  • 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]

1.0a2 - 2009-10-08

  • Make the generator factory work for all types of callables. [stefan]

  • Improve examples. [stefan]

1.0a1 - 2009-10-04

  • Initial release.

Metadata

Release files for rl 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rl 1.3
File Size Uploaded Provenance Actions
rl-1.3.zip 47.9 kB Without provenance Details for rl-1.3.zip

Release files / rl-1.3.zip

Download URL rl-1.3.zip
Size 47.9 kB
Tags Source
SHA-256 checksum
How to use checksums
801b035bf28607f6178674de0f40a573d6e812b48a8c58cf4f54b96ede1ec24b
BLAKE2b-256 checksum
How to use checksums
9e85ca764f643cef16fb03946119c42f4287b8c6c9be4020129978174c5b3e12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for rl 1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page