Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.

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.

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.

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

See the examples subdirectory of the package for more.

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.3. If you have not upgraded from 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.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.0a2

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.0a2
File Size Uploaded
rl-1.0a2.zip 36.0 kB Details

Release files / rl-1.0a2.zip

Download URL rl-1.0a2.zip
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0d903b6fa83f05f312f1f22c9813ee15ccca46570be00b79262466383342c620
BLAKE2b-256 checksum
How to use checksums
e39b072ecee1ee0fbd784300744865c76f403058b32b2bd5e849caf42edca9a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
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