Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / module-future.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="prev" href="module-main.html" />
13<link rel="parent" href="python.html" />
14<link rel="next" href="strings.html" />
15<meta name='aesop' content='information' />
16<title>3.34 __future__ -- Future statement definitions</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="3.33 __main__ "
24 href="module-main.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
27 href="python.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="4. String Services"
30 href="strings.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="module-main.html">3.33 __main__ </A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="strings.html">4. String Services</A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H1><A NAME="SECTION0053400000000000000000">
553.34 <tt class="module">__future__</tt> --
56 Future statement definitions</A>
57</H1>
58
59<P>
60<A NAME="module-future"></A>
61
62<P>
63<tt class="module">__future__</tt> is a real module, and serves three purposes:
64
65<P>
66
67<UL>
68<LI>To avoid confusing existing tools that analyze import statements
69 and expect to find the modules they're importing.
70
71<P>
72</LI>
73<LI>To ensure that future_statements run under releases prior to 2.1
74 at least yield runtime exceptions (the import of
75 <tt class="module">__future__</tt> will fail, because there was no module of
76 that name prior to 2.1).
77
78<P>
79</LI>
80<LI>To document when incompatible changes were introduced, and when they
81 will be -- or were -- made mandatory. This is a form of executable
82 documentation, and can be inspected programatically via importing
83 <tt class="module">__future__</tt> and examining its contents.
84
85<P>
86</LI>
87</UL>
88
89<P>
90Each statement in <span class="file">__future__.py</span> is of the form:
91
92<P>
93<div class="verbatim"><pre><TT>
94 FeatureName = &#34;_Feature(&#34; <var>OptionalRelease</var> &#34;,&#34; <var>MandatoryRelease</var> &#34;,&#34;
95 <var>CompilerFlag</var> &#34;)&#34;
96 </TT></pre></div>
97
98<P>
99where, normally, <var>OptionalRelease</var> is less than
100<var>MandatoryRelease</var>, and both are 5-tuples of the same form as
101<code>sys.version_info</code>:
102
103<P>
104<div class="verbatim"><pre>
105 (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int
106 PY_MINOR_VERSION, # the 1; an int
107 PY_MICRO_VERSION, # the 0; an int
108 PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string
109 PY_RELEASE_SERIAL # the 3; an int
110 )
111</pre></div>
112
113<P>
114<var>OptionalRelease</var> records the first release in which the feature
115was accepted.
116
117<P>
118In the case of a <var>MandatoryRelease</var> that has not yet occurred,
119<var>MandatoryRelease</var> predicts the release in which the feature will
120become part of the language.
121
122<P>
123Else <var>MandatoryRelease</var> records when the feature became part of
124the language; in releases at or after that, modules no longer need a
125future statement to use the feature in question, but may continue to
126use such imports.
127
128<P>
129<var>MandatoryRelease</var> may also be <code>None</code>, meaning that a planned
130feature got dropped.
131
132<P>
133Instances of class <tt class="class">_Feature</tt> have two corresponding methods,
134<tt class="method">getOptionalRelease()</tt> and <tt class="method">getMandatoryRelease()</tt>.
135
136<P>
137<var>CompilerFlag</var> is the (bitfield) flag that should be passed in the
138fourth argument to the builtin function <tt class="function">compile()</tt> to enable
139the feature in dynamically compiled code. This flag is stored in the
140<tt class="member">compiler_flag</tt> attribute on <tt class="class">_Future</tt> instances.
141
142<P>
143No feature description will ever be deleted from <tt class="module">__future__</tt>.
144
145<P>
146
147<DIV CLASS="navigation">
148<div class='online-navigation'>
149<p></p><hr />
150<table align="center" width="100%" cellpadding="0" cellspacing="2">
151<tr>
152<td class='online-navigation'><a rel="prev" title="3.33 __main__ "
153 href="module-main.html"><img src='../icons/previous.png'
154 border='0' height='32' alt='Previous Page' width='32' /></A></td>
155<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
156 href="python.html"><img src='../icons/up.png'
157 border='0' height='32' alt='Up One Level' width='32' /></A></td>
158<td class='online-navigation'><a rel="next" title="4. String Services"
159 href="strings.html"><img src='../icons/next.png'
160 border='0' height='32' alt='Next Page' width='32' /></A></td>
161<td align="center" width="100%">Python Library Reference</td>
162<td class='online-navigation'><a rel="contents" title="Table of Contents"
163 href="contents.html"><img src='../icons/contents.png'
164 border='0' height='32' alt='Contents' width='32' /></A></td>
165<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
166 border='0' height='32' alt='Module Index' width='32' /></a></td>
167<td class='online-navigation'><a rel="index" title="Index"
168 href="genindex.html"><img src='../icons/index.png'
169 border='0' height='32' alt='Index' width='32' /></A></td>
170</tr></table>
171<div class='online-navigation'>
172<b class="navlabel">Previous:</b>
173<a class="sectref" rel="prev" href="module-main.html">3.33 __main__ </A>
174<b class="navlabel">Up:</b>
175<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
176<b class="navlabel">Next:</b>
177<a class="sectref" rel="next" href="strings.html">4. String Services</A>
178</div>
179</div>
180<hr />
181<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
182</DIV>
183<!--End of Navigation Panel-->
184<ADDRESS>
185See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
186</ADDRESS>
187</BODY>
188</HTML>