Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / module-pycompile.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-compileall.html" />
13<link rel="prev" href="module-pyclbr.html" />
14<link rel="parent" href="language.html" />
15<link rel="next" href="module-compileall.html" />
16<meta name='aesop' content='information' />
17<title>18.8 py_compile -- Compile Python source files</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="18.7.2 Function Descriptor Objects"
25 href="pyclbr-function-objects.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="18. Python Language Services"
28 href="language.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="18.9 compileall "
31 href="module-compileall.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="pyclbr-function-objects.html">18.7.2 Function Descriptor Objects</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="language.html">18. Python Language Services</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-compileall.html">18.9 compileall </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0020800000000000000000">
5618.8 <tt class="module">py_compile</tt> --
57 Compile Python source files</A>
58</H1>
59
60<P>
61<A NAME="module-pycompile"></A>
62<P>
63
64<P>
65<a id='l2h-4993' xml:id='l2h-4993'></a>The <tt class="module">py_compile</tt> module provides a function to generate a
66byte-code file from a source file, and another function used when the
67module source file is invoked as a script.
68
69<P>
70Though not often needed, this function can be useful when installing
71modules for shared use, especially if some of the users may not have
72permission to write the byte-code cache files in the directory
73containing the source code.
74
75<P>
76<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-4994' xml:id='l2h-4994' class="exception">PyCompileError</tt></b></dt>
77<dd>
78Exception raised when an error occurs while attempting to compile the file.
79</dd></dl>
80
81<P>
82<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
83 <td><nobr><b><tt id='l2h-4995' xml:id='l2h-4995' class="function">compile</tt></b>(</nobr></td>
84 <td><var>file</var><big>[</big><var>, cfile</var><big>[</big><var>, dfile</var><big>[</big><var>, doraise</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
85<dd>
86 Compile a source file to byte-code and write out the byte-code cache
87 file. The source code is loaded from the file name <var>file</var>. The
88 byte-code is written to <var>cfile</var>, which defaults to <var>file</var>
89 <code>+</code> <code>'c'</code> (<code>'o'</code> if optimization is enabled in the
90 current interpreter). If <var>dfile</var> is specified, it is used as
91 the name of the source file in error messages instead of <var>file</var>.
92 If <var>doraise</var> = True, a PyCompileError is raised when an error is
93 encountered while compiling <var>file</var>. If <var>doraise</var> = False (the default),
94 an error string is written to sys.stderr, but no exception is raised.
95</dl>
96
97<P>
98<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
99 <td><nobr><b><tt id='l2h-4996' xml:id='l2h-4996' class="function">main</tt></b>(</nobr></td>
100 <td><var></var><big>[</big><var>args</var><big>]</big><var></var>)</td></tr></table></dt>
101<dd>
102 Compile several source files. The files named in <var>args</var> (or on
103 the command line, if <var>args</var> is not specified) are compiled and
104 the resulting bytecode is cached in the normal manner. This
105 function does not search a directory structure to locate source
106 files; it only compiles files named explicitly.
107</dl>
108
109<P>
110When this module is run as a script, the <tt class="function">main()</tt> is used to
111compile all the files named on the command line.
112
113<P>
114<div class="seealso">
115 <p class="heading">See Also:</p>
116
117 <dl compact="compact" class="seemodule">
118 <dt>Module <b><tt class="module"><a href="module-compileall.html">compileall</a></tt>:</b>
119 <dd>Utilities to compile all Python source files
120 in a directory tree.
121 </dl>
122</div>
123
124<DIV CLASS="navigation">
125<div class='online-navigation'>
126<p></p><hr />
127<table align="center" width="100%" cellpadding="0" cellspacing="2">
128<tr>
129<td class='online-navigation'><a rel="prev" title="18.7.2 Function Descriptor Objects"
130 href="pyclbr-function-objects.html"><img src='../icons/previous.png'
131 border='0' height='32' alt='Previous Page' width='32' /></A></td>
132<td class='online-navigation'><a rel="parent" title="18. Python Language Services"
133 href="language.html"><img src='../icons/up.png'
134 border='0' height='32' alt='Up One Level' width='32' /></A></td>
135<td class='online-navigation'><a rel="next" title="18.9 compileall "
136 href="module-compileall.html"><img src='../icons/next.png'
137 border='0' height='32' alt='Next Page' width='32' /></A></td>
138<td align="center" width="100%">Python Library Reference</td>
139<td class='online-navigation'><a rel="contents" title="Table of Contents"
140 href="contents.html"><img src='../icons/contents.png'
141 border='0' height='32' alt='Contents' width='32' /></A></td>
142<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
143 border='0' height='32' alt='Module Index' width='32' /></a></td>
144<td class='online-navigation'><a rel="index" title="Index"
145 href="genindex.html"><img src='../icons/index.png'
146 border='0' height='32' alt='Index' width='32' /></A></td>
147</tr></table>
148<div class='online-navigation'>
149<b class="navlabel">Previous:</b>
150<a class="sectref" rel="prev" href="pyclbr-function-objects.html">18.7.2 Function Descriptor Objects</A>
151<b class="navlabel">Up:</b>
152<a class="sectref" rel="parent" href="language.html">18. Python Language Services</A>
153<b class="navlabel">Next:</b>
154<a class="sectref" rel="next" href="module-compileall.html">18.9 compileall </A>
155</div>
156</div>
157<hr />
158<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
159</DIV>
160<!--End of Navigation Panel-->
161<ADDRESS>
162See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
163</ADDRESS>
164</BODY>
165</HTML>