append(): Fixing the test for convertability after consultation with
[python/dscho.git] / Doc / lib / libpycompile.tex
bloba28b4fe5e01f4961521bf4c14ea98bf458421a25
1 \section{\module{py_compile} ---
2 Compile Python source files}
4 % Documentation based on module docstrings, by Fred L. Drake, Jr.
5 % <fdrake@acm.org>
7 \declaremodule[pycompile]{standard}{py_compile}
9 \modulesynopsis{Compile Python source files to byte-code files.}
12 \indexii{file}{byte-code}
13 The \module{py_compile} module provides a function to generate a
14 byte-code file from a source file, and another function used when the
15 module source file is invoked as a script.
17 Though not often needed, this function can be useful when installing
18 modules for shared use, especially if some of the users may not have
19 permission to write the byte-code cache files in the directory
20 containing the source code.
23 \begin{funcdesc}{compile}{file\optional{, cfile\optional{, dfile}}}
24 Compile a source file to byte-code and write out the byte-code cache
25 file. The source code is loaded from the file name \var{file}. The
26 byte-code is written to \var{cfile}, which defaults to \var{file}
27 \code{+} \code{'c'} (\code{'o'} if optimization is enabled in the
28 current interpreter). If \var{dfile} is specified, it is used as
29 the name of the source file in error messages instead of \var{file}.
30 \end{funcdesc}
33 \begin{funcdesc}{main}{\optional{args}}
34 Compile several source files. The files named in \var{args} (or on
35 the command line, if \var{args} is not specified) are compiled and
36 the resulting bytecode is cached in the normal manner. This
37 function does not search a directory structure to locate source
38 files; it only compiles files named explicitly.
39 \end{funcdesc}
41 When this module is run as a script, the \function{main()} is used to
42 compile all the files named on the command line.
44 \begin{seealso}
45 \seemodule{compileall}{Utilities to compile all Python source files
46 in a directory tree.}
47 \end{seealso}