source: vendor/python/2.5/Doc/lib/libcode.tex

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 7.2 KB
Line 
1\section{\module{code} ---
2 Interpreter base classes}
3\declaremodule{standard}{code}
4
5\modulesynopsis{Base classes for interactive Python interpreters.}
6
7
8The \code{code} module provides facilities to implement
9read-eval-print loops in Python. Two classes and convenience
10functions are included which can be used to build applications which
11provide an interactive interpreter prompt.
12
13
14\begin{classdesc}{InteractiveInterpreter}{\optional{locals}}
15This class deals with parsing and interpreter state (the user's
16namespace); it does not deal with input buffering or prompting or
17input file naming (the filename is always passed in explicitly).
18The optional \var{locals} argument specifies the dictionary in
19which code will be executed; it defaults to a newly created
20dictionary with key \code{'__name__'} set to \code{'__console__'}
21and key \code{'__doc__'} set to \code{None}.
22\end{classdesc}
23
24\begin{classdesc}{InteractiveConsole}{\optional{locals\optional{, filename}}}
25Closely emulate the behavior of the interactive Python interpreter.
26This class builds on \class{InteractiveInterpreter} and adds
27prompting using the familiar \code{sys.ps1} and \code{sys.ps2}, and
28input buffering.