Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 :mod:`py_compile` --- Compile Python source files | 1 :mod:`py_compile` --- Compile Python source files |
2 ================================================= | 2 ================================================= |
3 | 3 |
4 .. module:: py_compile | 4 .. module:: py_compile |
5 :synopsis: Generate byte-code files from Python source files. | 5 :synopsis: Generate byte-code files from Python source files. |
6 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org> | 6 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org> |
7 .. documentation based on module docstrings | 7 .. documentation based on module docstrings |
8 | 8 |
9 .. index:: pair: file; byte-code | 9 .. index:: pair: file; byte-code |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 Compile a source file to byte-code and write out the byte-code cache file. The | 27 Compile a source file to byte-code and write out the byte-code cache file. The |
28 source code is loaded from the file name *file*. The byte-code is written t o | 28 source code is loaded from the file name *file*. The byte-code is written t o |
29 *cfile*, which defaults to the :PEP:`3147` path, ending in ``.pyc`` | 29 *cfile*, which defaults to the :PEP:`3147` path, ending in ``.pyc`` |
30 (``'.pyo`` if optimization is enabled in the current interpreter). For | 30 (``'.pyo`` if optimization is enabled in the current interpreter). For |
31 example, if *file* is ``/foo/bar/baz.py`` *cfile* will default to | 31 example, if *file* is ``/foo/bar/baz.py`` *cfile* will default to |
32 ``/foo/bar/__pycache__/baz.cpython-32.pyc`` for Python 3.2. If *dfile* is sp ecified, it is used as the | 32 ``/foo/bar/__pycache__/baz.cpython-32.pyc`` for Python 3.2. If *dfile* is sp ecified, it is used as the |
33 name of the source file in error messages instead of *file*. If *doraise* is | 33 name of the source file in error messages instead of *file*. If *doraise* is |
34 true, a :exc:`PyCompileError` is raised when an error is encountered while | 34 true, a :exc:`PyCompileError` is raised when an error is encountered while |
35 compiling *file*. If *doraise* is false (the default), an error string is | 35 compiling *file*. If *doraise* is false (the default), an error string is |
36 written to ``sys.stderr``, but no exception is raised. This function | 36 written to ``sys.stderr``, but no exception is raised. This function |
37 returns the path to byte-compilation file, i.e. whatever *cfile* value was | 37 returns the path to byte-compiled file, i.e. whatever *cfile* value was |
Georg
2010/04/10 19:07:56
better "byte-compiled file"?
barry
2010/04/12 21:59:05
Done.
| |
38 used. | 38 used. |
39 | 39 |
40 | 40 |
41 .. function:: main(args=None) | 41 .. function:: main(args=None) |
42 | 42 |
43 Compile several source files. The files named in *args* (or on the command | 43 Compile several source files. The files named in *args* (or on the command |
44 line, if *args* is ``None``) are compiled and the resulting bytecode is | 44 line, if *args* is ``None``) are compiled and the resulting bytecode is |
45 cached in the normal manner. This function does not search a directory | 45 cached in the normal manner. This function does not search a directory |
46 structure to locate source files; it only compiles files named explicitly. | 46 structure to locate source files; it only compiles files named explicitly. |
47 | 47 |
48 When this module is run as a script, the :func:`main` is used to compile all the | 48 When this module is run as a script, the :func:`main` is used to compile all the |
49 files named on the command line. The exit status is nonzero if one of the files | 49 files named on the command line. The exit status is nonzero if one of the files |
50 could not be compiled. | 50 could not be compiled. |
51 | 51 |
52 | 52 |
53 .. seealso:: | 53 .. seealso:: |
54 | 54 |
55 Module :mod:`compileall` | 55 Module :mod:`compileall` |
56 Utilities to compile all Python source files in a directory tree. | 56 Utilities to compile all Python source files in a directory tree. |
57 | 57 |
LEFT | RIGHT |