annotate Doc/lib/libcode.tex @ 8716:760dcf197048 legacy-trunk

Adjusted to use the new module synopsis support macros.
author Fred Drake <fdrake@acm.org>
date Thu, 23 Jul 1998 17:59:49 +0000
parents 8e5223680a9d
children acfffe14628e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7877
8e5223680a9d Remove all uses of \sectcode; we can now use logical markup everywhere.
Fred Drake <fdrake@acm.org>
parents: 7863
diff changeset
1 \section{Standard Module \module{code}}
8716
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
2 \declaremodule{standard}{code}
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
3
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
4 \modulesynopsis{Code object services.}
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
5
5842
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 The \code{code} module defines operations pertaining to Python code
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 objects.
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 The \code{code} module defines the following functions:
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
6960
319a51c381ce Nit adjustments to remove warnings when processed with partparse.py.
Fred Drake <fdrake@acm.org>
parents: 6896
diff changeset
13 \begin{funcdesc}{compile_command}{source, \optional{filename\optional{, symbol}}}
5842
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 This function is useful for programs that want to emulate Python's
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 interpreter main loop (a.k.a. the read-eval-print loop). The tricky
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 part is to determine when the user has entered an incomplete command
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 that can be completed by entering more text (as opposed to a complete
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 command or a syntax error). This function \emph{almost} always makes
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 the same decision as the real interpreter main loop.
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 Arguments: \var{source} is the source string; \var{filename} is the
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 optional filename from which source was read, defaulting to
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 \code{"<input>"}; and \var{symbol} is the optional grammar start
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 symbol, which should be either \code{"single"} (the default) or
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 \code{"eval"}.
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 Return a code object (the same as \code{compile(\var{source},
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 \var{filename}, \var{symbol})}) if the command is complete and valid;
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 return \code{None} if the command is incomplete; raise
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 \code{SyntaxError} if the command is a syntax error.
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
32
35b14d78c61d added code.py; codehack.py is obsolete
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 \end{funcdesc}