Vous devez avoir un compte Developpez.com et être connecté pour pouvoir participer aux discussions.

Identifiez-vous
Identifiant
Mot de passe
Mot de passe oublié ?
Créer un compte

Vous n'avez pas encore de compte Developpez.com ? L'inscription est gratuite et ne vous prendra que quelques instants !

Je m'inscris !

Developpez.com

Python

Choisissez la catégorie, puis la rubrique :

15.7 readline -- GNU readline interface

15.7 readline -- GNU readline interface

Availability: Unix.

The readline module defines a number of functions to facilitate completion and reading/writing of history files from the Python interpreter. This module can be used directly or via the rlcompleter module. Settings made using this module affect the behaviour of both the interpreter's interactive prompt and the prompts offered by the raw_input() and input() built-in functions.

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.
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web