Quick update to the README file. For intros and books we now point to
[python/dscho.git] / Doc / lib / libcode.tex
blob877b7a4eb0bb5ab68e1725673e833aa920d397a1
1 \section{\module{code} ---
2 Code object services.}
3 \declaremodule{standard}{code}
5 \modulesynopsis{Code object services.}
8 The \code{code} module defines operations pertaining to Python code
9 objects. It defines the following function:
12 \begin{funcdesc}{compile_command}{source, \optional{filename\optional{, symbol}}}
13 This function is useful for programs that want to emulate Python's
14 interpreter main loop (a.k.a. the read-eval-print loop). The tricky
15 part is to determine when the user has entered an incomplete command
16 that can be completed by entering more text (as opposed to a complete
17 command or a syntax error). This function \emph{almost} always makes
18 the same decision as the real interpreter main loop.
20 Arguments: \var{source} is the source string; \var{filename} is the
21 optional filename from which source was read, defaulting to
22 \code{'<input>'}; and \var{symbol} is the optional grammar start
23 symbol, which should be either \code{'single'} (the default) or
24 \code{'eval'}.
26 Return a code object (the same as \code{compile(\var{source},
27 \var{filename}, \var{symbol})}) if the command is complete and valid;
28 return \code{None} if the command is incomplete; raise
29 \exception{SyntaxError} if the command is a syntax error.
30 \end{funcdesc}