ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
ActivePython 2.4
Python Documentation
Library Reference
7. Optional Operating System Services
7.1 signal -- Set handlers for asynchronous events
7.2 socket -- Low-level networking interface
7.3 select -- Waiting for I/O completion
7.4 thread -- Multiple threads of control
7.5 threading -- Higher-level threading interface
7.6 dummy thread -- Drop-in replacement for the thread module
7.7 dummy threading -- Drop-in replacement for the threading module
7.8 Queue -- A synchronized queue class
7.9 mmap -- Memory-mapped file support
7.10 anydbm -- Generic access to DBM-style databases
7.11 dbhash -- DBM-style interface to the BSD database library
7.12 whichdb -- Guess which DBM module created a database
7.13 bsddb -- Interface to Berkeley DB library
7.14 dumbdbm -- Portable DBM implementation
7.15 zlib -- Compression compatible with gzip
7.16 gzip -- Support for gzip files
7.17 bz2 -- Compression compatible with bzip2
7.18 zipfile -- Work with ZIP archives
7.19 tarfile -- Read and write tar archive files
7.20 readline -- GNU readline interface
7.20.1 Example
7.21 rlcompleter -- Completion function for GNU readline

MyASPN >> Reference >> ActivePython 2.4 >> Python Documentation >> Library Reference >> 7. Optional Operating System Services
ActivePython 2.4 documentation

7.20 readline -- GNU readline interface

Availability: Unix.

The readline module defines a number of functions used either directly or from the rlcompleter module to facilitate completion and history file read and write from the Python interpreter.

The readline module defines the following functions:

parse_and_bind( string)
Parse and execute single line of a readline init file.

get_line_buffer( )
Return the current contents of the line buffer.

insert_text( string)
Insert text into the command line.

read_init_file( [filename])
Parse a readline initialization file. The default filename is the last filename used.

read_history_file( [filename])
Load a readline history file. The default filename is ~/.history.

write_history_file( [filename])
Save a readline history file. The default filename is ~/.history.

clear_history( )
Clear the current history. (Note: this function is not available if the installed version of GNU readline doesn't support it.) New in version 2.4.

get_history_length( )
Return the desired length of the history file. Negative values imply unlimited history file size.

set_history_length( length)
Set the number of lines to save in the history file. write_history_file() uses this value to truncate the history file when saving. Negative values imply unlimited history file size.

get_current_history_length( )
Return the number of lines currently in the history. (This is different from get_history_length(), which returns the maximum number of lines that will be written to a history file.) New in version 2.3.

get_history_item( index)
Return the current contents of history item at index. New in version 2.3.

remove_history_item( pos)
Remove history item specified by its position from the history. New in version 2.4.

replace_history_item( pos, line)
Replace history item specified by its position with the given line. New in version 2.4.

redisplay( )
Change what's displayed on the screen to reflect the current contents of the line buffer. New in version 2.3.

set_startup_hook( [function])
Set or remove the startup_hook function. If function is specified, it will be used as the new startup_hook function; if omitted or None, any hook function already installed is removed. The startup_hook function is called with no arguments just before readline prints the first prompt.

set_pre_input_hook( [function])
Set or remove the pre_input_hook function. If function is specified, it will be used as the new pre_input_hook function; if omitted or None, any hook function already installed is removed. The pre_input_hook function is called with no arguments after the first prompt has been printed and just before readline starts reading input characters.

set_completer( [function])
Set or remove the completer function. If function is specified, it will be used as the new completer function; if omitted or None, any completer function already installed is removed. The completer function is called as function(text, state), for state in 0, 1, 2, ..., until it returns a non-string value. It should return the next possible completion starting with text.

get_completer( )
Get the completer function, or None if no completer function has been set. New in version 2.3.

get_begidx( )
Get the beginning index of the readline tab-completion scope.

get_endidx( )
Get the ending index of the readline tab-completion scope.

set_completer_delims( string)
Set the readline word delimiters for tab-completion.

get_completer_delims( )
Get the readline word delimiters for tab-completion.

add_history( line)
Append a line to the history buffer, as if it was the last line typed.

See Also:

Module rlcompleter:
Completion of Python identifiers at the interactive prompt.



See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved