annotate Doc/lib/libcodeop.tex @ 17581:c1937faabb23 2.1

Added support for optional explanation parameter to the \versionadded macro. Refactored do_cmd_versionadded() and do_cmd_versionchanged() to do most of the work in a helper function, with the do_cmd_*() wrappers just supplying a portion of the replacement text.
author Fred Drake <fdrake@acm.org>
date Wed, 18 Apr 2001 17:29:14 +0000
parents d7864345b1c8
children 17b2afba7a6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{codeop} ---
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 Compile Python code}
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
4 % LaTeXed from excellent doc-string.
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
5
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6 \declaremodule{standard}{codeop}
15467
d7864345b1c8 Update Moshe Zadka's email address to one works and might last a while.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
7 \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8 \modulesynopsis{Compile (possibly incomplete) Python code.}
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 The \module{codeop} module provides a function to compile Python code
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
11 with hints on whether it is certainly complete, possibly complete or
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12 definitely incomplete. This is used by the \refmodule{code} module
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13 and should not normally be used directly.
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 The \module{codeop} module defines the following function:
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17 \begin{funcdesc}{compile_command}
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18 {source\optional{, filename\optional{, symbol}}}
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
19 Tries to compile \var{source}, which should be a string of Python
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
20 code and return a code object if \var{source} is valid
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21 Python code. In that case, the filename attribute of the code object
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
22 will be \var{filename}, which defaults to \code{'<input>'}.
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
23 Returns \code{None} if \var{source} is \emph{not} valid Python
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24 code, but is a prefix of valid Python code.
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
26 If there is a problem with \var{source}, an exception will be raised.
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
27 \exception{SyntaxError} is raised if there is invalid Python syntax,
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
28 and \exception{OverflowError} if there is an invalid numeric
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
29 constant.
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
31 The \var{symbol} argument determines whether \var{source} is compiled
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
32 as a statement (\code{'single'}, the default) or as an expression
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
33 (\code{'eval'}). Any other value will cause \exception{ValueError} to
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11036
diff changeset
34 be raised.
11036
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36 \strong{Caveat:}
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 It is possible (but not likely) that the parser stops parsing
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 with a successful outcome before reaching the end of the source;
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
39 in this case, trailing symbols may be ignored instead of causing an
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 error. For example, a backslash followed by two newlines may be
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41 followed by arbitrary garbage. This will be fixed once the API
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
42 for the parser is better.
5adbb3f04cbc Two more from Moshe!
Fred Drake <fdrake@acm.org>
parents:
diff changeset
43 \end{funcdesc}