Commit | Line | Data |
---|---|---|
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="non-essential-built-in-funcs.html" /> | |
13 | <link rel="prev" href="builtin.html" /> | |
14 | <link rel="parent" href="builtin.html" /> | |
15 | <link rel="next" href="non-essential-built-in-funcs.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>2.1 Built-in Functions </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="2. Built-In Objects" | |
25 | href="builtin.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="2. Built-In Objects" | |
28 | href="builtin.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="2.2 Non-essential Built-in Functions" | |
31 | href="non-essential-built-in-funcs.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="builtin.html">2. Built-In Objects</A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="builtin.html">2. Built-In Objects</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="non-essential-built-in-funcs.html">2.2 Non-essential Built-in Functions</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION004100000000000000000"></A><A NAME="built-in-funcs"></A> | |
56 | <BR> | |
57 | 2.1 Built-in Functions | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | The Python interpreter has a number of functions built into it that | |
62 | are always available. They are listed here in alphabetical order. | |
63 | ||
64 | <P> | |
65 | ||
66 | <P> | |
67 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
68 | <td><nobr><b><tt id='l2h-6' xml:id='l2h-6' class="function">__import__</tt></b>(</nobr></td> | |
69 | <td><var>name</var><big>[</big><var>, globals</var><big>[</big><var>, locals</var><big>[</big><var>, fromlist</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
70 | <dd> | |
71 | This function is invoked by the <tt class="keyword">import</tt><a id='l2h-7' xml:id='l2h-7'></a> statement. It mainly exists so that you can replace it with another | |
72 | function that has a compatible interface, in order to change the | |
73 | semantics of the <tt class="keyword">import</tt> statement. For examples of why | |
74 | and how you would do this, see the standard library modules | |
75 | <tt class="module">ihooks</tt><a id='l2h-80' xml:id='l2h-80'></a> and | |
76 | <tt class="module"><a href="module-rexec.html">rexec</a></tt><a id='l2h-81' xml:id='l2h-81'></a>. See also the built-in | |
77 | module <tt class="module"><a href="module-imp.html">imp</a></tt><a id='l2h-82' xml:id='l2h-82'></a>, which defines some useful | |
78 | operations out of which you can build your own | |
79 | <tt class="function">__import__()</tt> function. | |
80 | ||
81 | <P> | |
82 | For example, the statement "<tt class="samp">import spam</tt>" results in the | |
83 | following call: <code>__import__('spam',</code> <code>globals(),</code> | |
84 | <code>locals(), [])</code>; the statement "<tt class="samp">from spam.ham import eggs</tt>" results in "<tt class="samp">__import__('spam.ham', globals(), locals(), | |
85 | ['eggs'])</tt>". Note that even though <code>locals()</code> and | |
86 | <code>['eggs']</code> are passed in as arguments, the | |
87 | <tt class="function">__import__()</tt> function does not set the local variable | |
88 | named <code>eggs</code>; this is done by subsequent code that is generated | |
89 | for the import statement. (In fact, the standard implementation | |
90 | does not use its <var>locals</var> argument at all, and uses its | |
91 | <var>globals</var> only to determine the package context of the | |
92 | <tt class="keyword">import</tt> statement.) | |
93 | ||
94 | <P> | |
95 | When the <var>name</var> variable is of the form <code>package.module</code>, | |
96 | normally, the top-level package (the name up till the first dot) is | |
97 | returned, <em>not</em> the module named by <var>name</var>. However, when | |
98 | a non-empty <var>fromlist</var> argument is given, the module named by | |
99 | <var>name</var> is returned. This is done for compatibility with the | |
100 | bytecode generated for the different kinds of import statement; when | |
101 | using "<tt class="samp">import spam.ham.eggs</tt>", the top-level package <tt class="module">spam</tt> | |
102 | must be placed in the importing namespace, but when using "<tt class="samp">from | |
103 | spam.ham import eggs</tt>", the <code>spam.ham</code> subpackage must be used | |
104 | to find the <code>eggs</code> variable. As a workaround for this | |
105 | behavior, use <tt class="function">getattr()</tt> to extract the desired | |
106 | components. For example, you could define the following helper: | |
107 | ||
108 | <P> | |
109 | <div class="verbatim"><pre> | |
110 | def my_import(name): | |
111 | mod = __import__(name) | |
112 | components = name.split('.') | |
113 | for comp in components[1:]: | |
114 | mod = getattr(mod, comp) | |
115 | return mod | |
116 | </pre></div> | |
117 | </dl> | |
118 | ||
119 | <P> | |
120 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
121 | <td><nobr><b><tt id='l2h-8' xml:id='l2h-8' class="function">abs</tt></b>(</nobr></td> | |
122 | <td><var>x</var>)</td></tr></table></dt> | |
123 | <dd> | |
124 | Return the absolute value of a number. The argument may be a plain | |
125 | or long integer or a floating point number. If the argument is a | |
126 | complex number, its magnitude is returned. | |
127 | </dl> | |
128 | ||
129 | <P> | |
130 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
131 | <td><nobr><b><tt id='l2h-9' xml:id='l2h-9' class="function">basestring</tt></b>(</nobr></td> | |
132 | <td><var></var>)</td></tr></table></dt> | |
133 | <dd> | |
134 | This abstract type is the superclass for <tt class="class">str</tt> and <tt class="class">unicode</tt>. | |
135 | It cannot be called or instantiated, but it can be used to test whether | |
136 | an object is an instance of <tt class="class">str</tt> or <tt class="class">unicode</tt>. | |
137 | <code>isinstance(obj, basestring)</code> is equivalent to | |
138 | <code>isinstance(obj, (str, unicode))</code>. | |
139 | ||
140 | <span class="versionnote">New in version 2.3.</span> | |
141 | ||
142 | </dl> | |
143 | ||
144 | <P> | |
145 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
146 | <td><nobr><b><tt id='l2h-10' xml:id='l2h-10' class="function">bool</tt></b>(</nobr></td> | |
147 | <td><var></var><big>[</big><var>x</var><big>]</big><var></var>)</td></tr></table></dt> | |
148 | <dd> | |
149 | Convert a value to a Boolean, using the standard truth testing | |
150 | procedure. If <var>x</var> is false or omitted, this returns | |
151 | <tt class="constant">False</tt>; otherwise it returns <tt class="constant">True</tt>. | |
152 | <tt class="class">bool</tt> is also a class, which is a subclass of <tt class="class">int</tt>. | |
153 | Class <tt class="class">bool</tt> cannot be subclassed further. Its only instances | |
154 | are <tt class="constant">False</tt> and <tt class="constant">True</tt>. | |
155 | ||
156 | <P> | |
157 | <a id='l2h-11' xml:id='l2h-11'></a> | |
158 | <span class="versionnote">New in version 2.2.1.</span> | |
159 | ||
160 | <span class="versionnote">Changed in version 2.3: | |
161 | If no argument is given, this function returns | |
162 | <tt class="constant">False</tt>.</span> | |
163 | ||
164 | </dl> | |
165 | ||
166 | <P> | |
167 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
168 | <td><nobr><b><tt id='l2h-12' xml:id='l2h-12' class="function">callable</tt></b>(</nobr></td> | |
169 | <td><var>object</var>)</td></tr></table></dt> | |
170 | <dd> | |
171 | Return true if the <var>object</var> argument appears callable, false if | |
172 | not. If this returns true, it is still possible that a call fails, | |
173 | but if it is false, calling <var>object</var> will never succeed. Note | |
174 | that classes are callable (calling a class returns a new instance); | |
175 | class instances are callable if they have a <tt class="method">__call__()</tt> | |
176 | method. | |
177 | </dl> | |
178 | ||
179 | <P> | |
180 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
181 | <td><nobr><b><tt id='l2h-13' xml:id='l2h-13' class="function">chr</tt></b>(</nobr></td> | |
182 | <td><var>i</var>)</td></tr></table></dt> | |
183 | <dd> | |
184 | Return a string of one character whose ASCII code is the integer | |
185 | <var>i</var>. For example, <code>chr(97)</code> returns the string <code>'a'</code>. | |
186 | This is the inverse of <tt class="function">ord()</tt>. The argument must be in | |
187 | the range [0..255], inclusive; <tt class="exception">ValueError</tt> will be raised | |
188 | if <var>i</var> is outside that range. | |
189 | </dl> | |
190 | ||
191 | <P> | |
192 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
193 | <td><nobr><b><tt id='l2h-14' xml:id='l2h-14' class="function">classmethod</tt></b>(</nobr></td> | |
194 | <td><var>function</var>)</td></tr></table></dt> | |
195 | <dd> | |
196 | Return a class method for <var>function</var>. | |
197 | ||
198 | <P> | |
199 | A class method receives the class as implicit first argument, | |
200 | just like an instance method receives the instance. | |
201 | To declare a class method, use this idiom: | |
202 | ||
203 | <P> | |
204 | <div class="verbatim"><pre> | |
205 | class C: | |
206 | @classmethod | |
207 | def f(cls, arg1, arg2, ...): ... | |
208 | </pre></div> | |
209 | ||
210 | <P> | |
211 | The <code>@classmethod</code> form is a function decorator - see the description | |
212 | of function definitions in chapter 7 of the | |
213 | <em class="citetitle"><a | |
214 | href="../ref/ref.html" | |
215 | title="Python Reference Manual" | |
216 | >Python Reference Manual</a></em> for details. | |
217 | ||
218 | <P> | |
219 | It can be called either on the class (such as <code>C.f()</code>) or on an | |
220 | instance (such as <code>C().f()</code>). The instance is ignored except for | |
221 | its class. | |
222 | If a class method is called for a derived class, the derived class | |
223 | object is passed as the implied first argument. | |
224 | ||
225 | <P> | |
226 | Class methods are different than C++ or Java static methods. | |
227 | If you want those, see <tt class="function">staticmethod()</tt> in this section. | |
228 | ||
229 | <span class="versionnote">New in version 2.2.</span> | |
230 | ||
231 | <span class="versionnote">Changed in version 2.4: | |
232 | Function decorator syntax added.</span> | |
233 | ||
234 | </dl> | |
235 | ||
236 | <P> | |
237 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
238 | <td><nobr><b><tt id='l2h-15' xml:id='l2h-15' class="function">cmp</tt></b>(</nobr></td> | |
239 | <td><var>x, y</var>)</td></tr></table></dt> | |
240 | <dd> | |
241 | Compare the two objects <var>x</var> and <var>y</var> and return an integer | |
242 | according to the outcome. The return value is negative if <code><var>x</var> | |
243 | < <var>y</var></code>, zero if <code><var>x</var> == <var>y</var></code> and strictly positive if | |
244 | <code><var>x</var> > <var>y</var></code>. | |
245 | </dl> | |
246 | ||
247 | <P> | |
248 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
249 | <td><nobr><b><tt id='l2h-16' xml:id='l2h-16' class="function">compile</tt></b>(</nobr></td> | |
250 | <td><var>string, filename, kind</var><big>[</big><var>, | |
251 | flags</var><big>[</big><var>, dont_inherit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
252 | <dd> | |
253 | Compile the <var>string</var> into a code object. Code objects can be | |
254 | executed by an <tt class="keyword">exec</tt> statement or evaluated by a call to | |
255 | <tt class="function">eval()</tt>. The <var>filename</var> argument should | |
256 | give the file from which the code was read; pass some recognizable value | |
257 | if it wasn't read from a file (<code>'<string>'</code> is commonly used). | |
258 | The <var>kind</var> argument specifies what kind of code must be | |
259 | compiled; it can be <code>'exec'</code> if <var>string</var> consists of a | |
260 | sequence of statements, <code>'eval'</code> if it consists of a single | |
261 | expression, or <code>'single'</code> if it consists of a single | |
262 | interactive statement (in the latter case, expression statements | |
263 | that evaluate to something else than <code>None</code> will be printed). | |
264 | ||
265 | <P> | |
266 | When compiling multi-line statements, two caveats apply: line | |
267 | endings must be represented by a single newline character | |
268 | (<code>'\n'</code>), and the input must be terminated by at least one | |
269 | newline character. If line endings are represented by | |
270 | <code>'\r\n'</code>, use the string <tt class="method">replace()</tt> method to | |
271 | change them into <code>'\n'</code>. | |
272 | ||
273 | <P> | |
274 | The optional arguments <var>flags</var> and <var>dont_inherit</var> | |
275 | (which are new in Python 2.2) control which future statements (see | |
276 | <a class="rfc" id='rfcref-85712' xml:id='rfcref-85712' | |
277 | href="http://www.python.org/peps/pep-0236.html">PEP 236</a>) affect the compilation of <var>string</var>. If neither is | |
278 | present (or both are zero) the code is compiled with those future | |
279 | statements that are in effect in the code that is calling compile. | |
280 | If the <var>flags</var> argument is given and <var>dont_inherit</var> is not | |
281 | (or is zero) then the future statements specified by the <var>flags</var> | |
282 | argument are used in addition to those that would be used anyway. | |
283 | If <var>dont_inherit</var> is a non-zero integer then the <var>flags</var> | |
284 | argument is it - the future statements in effect around the call to | |
285 | compile are ignored. | |
286 | ||
287 | <P> | |
288 | Future statements are specified by bits which can be bitwise or-ed | |
289 | together to specify multiple statements. The bitfield required to | |
290 | specify a given feature can be found as the <tt class="member">compiler_flag</tt> | |
291 | attribute on the <tt class="class">_Feature</tt> instance in the | |
292 | <tt class="module">__future__</tt> module. | |
293 | </dl> | |
294 | ||
295 | <P> | |
296 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
297 | <td><nobr><b><tt id='l2h-17' xml:id='l2h-17' class="function">complex</tt></b>(</nobr></td> | |
298 | <td><var></var><big>[</big><var>real</var><big>[</big><var>, imag</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
299 | <dd> | |
300 | Create a complex number with the value <var>real</var> + <var>imag</var>*j or | |
301 | convert a string or number to a complex number. If the first | |
302 | parameter is a string, it will be interpreted as a complex number | |
303 | and the function must be called without a second parameter. The | |
304 | second parameter can never be a string. | |
305 | Each argument may be any numeric type (including complex). | |
306 | If <var>imag</var> is omitted, it defaults to zero and the function | |
307 | serves as a numeric conversion function like <tt class="function">int()</tt>, | |
308 | <tt class="function">long()</tt> and <tt class="function">float()</tt>. If both arguments | |
309 | are omitted, returns <code>0j</code>. | |
310 | </dl> | |
311 | ||
312 | <P> | |
313 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
314 | <td><nobr><b><tt id='l2h-18' xml:id='l2h-18' class="function">delattr</tt></b>(</nobr></td> | |
315 | <td><var>object, name</var>)</td></tr></table></dt> | |
316 | <dd> | |
317 | This is a relative of <tt class="function">setattr()</tt>. The arguments are an | |
318 | object and a string. The string must be the name | |
319 | of one of the object's attributes. The function deletes | |
320 | the named attribute, provided the object allows it. For example, | |
321 | <code>delattr(<var>x</var>, '<var>foobar</var>')</code> is equivalent to | |
322 | <code>del <var>x</var>.<var>foobar</var></code>. | |
323 | </dl> | |
324 | ||
325 | <P> | |
326 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
327 | <td><nobr><b><tt id='l2h-19' xml:id='l2h-19' class="function">dict</tt></b>(</nobr></td> | |
328 | <td><var></var><big>[</big><var>mapping-or-sequence</var><big>]</big><var></var>)</td></tr></table></dt> | |
329 | <dd> | |
330 | Return a new dictionary initialized from an optional positional | |
331 | argument or from a set of keyword arguments. | |
332 | If no arguments are given, return a new empty dictionary. | |
333 | If the positional argument is a mapping object, return a dictionary | |
334 | mapping the same keys to the same values as does the mapping object. | |
335 | Otherwise the positional argument must be a sequence, a container that | |
336 | supports iteration, or an iterator object. The elements of the argument | |
337 | must each also be of one of those kinds, and each must in turn contain | |
338 | exactly two objects. The first is used as a key in the new dictionary, | |
339 | and the second as the key's value. If a given key is seen more than | |
340 | once, the last value associated with it is retained in the new | |
341 | dictionary. | |
342 | ||
343 | <P> | |
344 | If keyword arguments are given, the keywords themselves with their | |
345 | associated values are added as items to the dictionary. If a key | |
346 | is specified both in the positional argument and as a keyword argument, | |
347 | the value associated with the keyword is retained in the dictionary. | |
348 | For example, these all return a dictionary equal to | |
349 | <code>{"one": 2, "two": 3}</code>: | |
350 | ||
351 | <P> | |
352 | ||
353 | <UL> | |
354 | <LI><code>dict({'one': 2, 'two': 3})</code> | |
355 | </LI> | |
356 | <LI><code>dict({'one': 2, 'two': 3}.items())</code> | |
357 | </LI> | |
358 | <LI><code>dict({'one': 2, 'two': 3}.iteritems())</code> | |
359 | </LI> | |
360 | <LI><code>dict(zip(('one', 'two'), (2, 3)))</code> | |
361 | </LI> | |
362 | <LI><code>dict([['two', 3], ['one', 2]])</code> | |
363 | </LI> | |
364 | <LI><code>dict(one=2, two=3)</code> | |
365 | </LI> | |
366 | <LI><code>dict([(['one', 'two'][i-2], i) for i in (2, 3)])</code> | |
367 | ||
368 | </LI> | |
369 | </UL> | |
370 | ||
371 | <P> | |
372 | ||
373 | <span class="versionnote">New in version 2.2.</span> | |
374 | ||
375 | <span class="versionnote">Changed in version 2.3: | |
376 | Support for building a dictionary from keyword | |
377 | arguments added.</span> | |
378 | ||
379 | </dl> | |
380 | ||
381 | <P> | |
382 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
383 | <td><nobr><b><tt id='l2h-20' xml:id='l2h-20' class="function">dir</tt></b>(</nobr></td> | |
384 | <td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt> | |
385 | <dd> | |
386 | Without arguments, return the list of names in the current local | |
387 | symbol table. With an argument, attempts to return a list of valid | |
388 | attributes for that object. This information is gleaned from the | |
389 | object's <tt class="member">__dict__</tt> attribute, if defined, and from the class | |
390 | or type object. The list is not necessarily complete. | |
391 | If the object is a module object, the list contains the names of the | |
392 | module's attributes. | |
393 | If the object is a type or class object, | |
394 | the list contains the names of its attributes, | |
395 | and recursively of the attributes of its bases. | |
396 | Otherwise, the list contains the object's attributes' names, | |
397 | the names of its class's attributes, | |
398 | and recursively of the attributes of its class's base classes. | |
399 | The resulting list is sorted alphabetically. | |
400 | For example: | |
401 | ||
402 | <P> | |
403 | <div class="verbatim"><pre> | |
404 | >>> import struct | |
405 | >>> dir() | |
406 | ['__builtins__', '__doc__', '__name__', 'struct'] | |
407 | >>> dir(struct) | |
408 | ['__doc__', '__name__', 'calcsize', 'error', 'pack', 'unpack'] | |
409 | </pre></div> | |
410 | ||
411 | <P> | |
412 | <span class="note"><b class="label">Note:</b> | |
413 | Because <tt class="function">dir()</tt> is supplied primarily as a convenience | |
414 | for use at an interactive prompt, | |
415 | it tries to supply an interesting set of names more than it tries to | |
416 | supply a rigorously or consistently defined set of names, | |
417 | and its detailed behavior may change across releases.</span> | |
418 | </dl> | |
419 | ||
420 | <P> | |
421 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
422 | <td><nobr><b><tt id='l2h-21' xml:id='l2h-21' class="function">divmod</tt></b>(</nobr></td> | |
423 | <td><var>a, b</var>)</td></tr></table></dt> | |
424 | <dd> | |
425 | Take two (non complex) numbers as arguments and return a pair of numbers | |
426 | consisting of their quotient and remainder when using long division. With | |
427 | mixed operand types, the rules for binary arithmetic operators apply. For | |
428 | plain and long integers, the result is the same as | |
429 | <code>(<var>a</var> / <var>b</var>, <var>a</var> % <var>b</var>)</code>. | |
430 | For floating point numbers the result is <code>(<var>q</var>, <var>a</var> % | |
431 | <var>b</var>)</code>, where <var>q</var> is usually <code>math.floor(<var>a</var> / | |
432 | <var>b</var>)</code> but may be 1 less than that. In any case <code><var>q</var> * | |
433 | <var>b</var> + <var>a</var> % <var>b</var></code> is very close to <var>a</var>, if | |
434 | <code><var>a</var> % <var>b</var></code> is non-zero it has the same sign as | |
435 | <var>b</var>, and <code>0 <= abs(<var>a</var> % <var>b</var>) < abs(<var>b</var>)</code>. | |
436 | ||
437 | <P> | |
438 | ||
439 | <span class="versionnote">Changed in version 2.3: | |
440 | Using <tt class="function">divmod()</tt> with complex numbers is | |
441 | deprecated.</span> | |
442 | ||
443 | </dl> | |
444 | ||
445 | <P> | |
446 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
447 | <td><nobr><b><tt id='l2h-22' xml:id='l2h-22' class="function">enumerate</tt></b>(</nobr></td> | |
448 | <td><var>iterable</var>)</td></tr></table></dt> | |
449 | <dd> | |
450 | Return an enumerate object. <var>iterable</var> must be a sequence, an | |
451 | iterator, or some other object which supports iteration. The | |
452 | <tt class="method">next()</tt> method of the iterator returned by | |
453 | <tt class="function">enumerate()</tt> returns a tuple containing a count (from | |
454 | zero) and the corresponding value obtained from iterating over | |
455 | <var>iterable</var>. <tt class="function">enumerate()</tt> is useful for obtaining an | |
456 | indexed series: <code>(0, seq[0])</code>, <code>(1, seq[1])</code>, <code>(2, | |
457 | seq[2])</code>, .... | |
458 | ||
459 | <span class="versionnote">New in version 2.3.</span> | |
460 | ||
461 | </dl> | |
462 | ||
463 | <P> | |
464 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
465 | <td><nobr><b><tt id='l2h-23' xml:id='l2h-23' class="function">eval</tt></b>(</nobr></td> | |
466 | <td><var>expression</var><big>[</big><var>, globals</var><big>[</big><var>, locals</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
467 | <dd> | |
468 | The arguments are a string and optional globals and locals. If provided, | |
469 | <var>globals</var> must be a dictionary. If provided, <var>locals</var> can be | |
470 | any mapping object. | |
471 | <span class="versionnote">Changed in version 2.4: | |
472 | formerly <var>locals</var> was required | |
473 | to be a dictionary.</span> | |
474 | ||
475 | <P> | |
476 | The <var>expression</var> argument is parsed and evaluated as a Python | |
477 | expression (technically speaking, a condition list) using the | |
478 | <var>globals</var> and <var>locals</var> dictionaries as global and local name | |
479 | space. If the <var>globals</var> dictionary is present and lacks | |
480 | '__builtins__', the current globals are copied into <var>globals</var> before | |
481 | <var>expression</var> is parsed. This means that <var>expression</var> | |
482 | normally has full access to the standard | |
483 | <tt class="module"><a href="module-builtin.html">__builtin__</a></tt> module and restricted environments | |
484 | are propagated. If the <var>locals</var> dictionary is omitted it defaults to | |
485 | the <var>globals</var> dictionary. If both dictionaries are omitted, the | |
486 | expression is executed in the environment where <tt class="keyword">eval</tt> is | |
487 | called. The return value is the result of the evaluated expression. | |
488 | Syntax errors are reported as exceptions. Example: | |
489 | ||
490 | <P> | |
491 | <div class="verbatim"><pre> | |
492 | >>> x = 1 | |
493 | >>> print eval('x+1') | |
494 | 2 | |
495 | </pre></div> | |
496 | ||
497 | <P> | |
498 | This function can also be used to execute arbitrary code objects | |
499 | (such as those created by <tt class="function">compile()</tt>). In this case pass | |
500 | a code object instead of a string. The code object must have been | |
501 | compiled passing <code>'eval'</code> as the <var>kind</var> argument. | |
502 | ||
503 | <P> | |
504 | Hints: dynamic execution of statements is supported by the | |
505 | <tt class="keyword">exec</tt> statement. Execution of statements from a file is | |
506 | supported by the <tt class="function">execfile()</tt> function. The | |
507 | <tt class="function">globals()</tt> and <tt class="function">locals()</tt> functions returns the | |
508 | current global and local dictionary, respectively, which may be | |
509 | useful to pass around for use by <tt class="function">eval()</tt> or | |
510 | <tt class="function">execfile()</tt>. | |
511 | </dl> | |
512 | ||
513 | <P> | |
514 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
515 | <td><nobr><b><tt id='l2h-24' xml:id='l2h-24' class="function">execfile</tt></b>(</nobr></td> | |
516 | <td><var>filename</var><big>[</big><var>, globals</var><big>[</big><var>, locals</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
517 | <dd> | |
518 | This function is similar to the | |
519 | <tt class="keyword">exec</tt> statement, but parses a file instead of a string. It | |
520 | is different from the <tt class="keyword">import</tt> statement in that it does not | |
521 | use the module administration -- it reads the file unconditionally | |
522 | and does not create a new module.<A NAME="tex2html2" | |
523 | HREF="#foot394"><SUP>2.2</SUP></A> | |
524 | <P> | |
525 | The arguments are a file name and two optional dictionaries. The file is | |
526 | parsed and evaluated as a sequence of Python statements (similarly to a | |
527 | module) using the <var>globals</var> and <var>locals</var> dictionaries as global and | |
528 | local namespace. If provided, <var>locals</var> can be any mapping object. | |
529 | ||
530 | <span class="versionnote">Changed in version 2.4: | |
531 | formerly <var>locals</var> was required to be a dictionary.</span> | |
532 | ||
533 | If the <var>locals</var> dictionary is omitted it defaults to the <var>globals</var> | |
534 | dictionary. If both dictionaries are omitted, the expression is executed in | |
535 | the environment where <tt class="function">execfile()</tt> is called. The return value is | |
536 | <code>None</code>. | |
537 | ||
538 | <P> | |
539 | <span class="warning"><b class="label">Warning:</b> | |
540 | The default <var>locals</var> act as described for function | |
541 | <tt class="function">locals()</tt> below: modifications to the default <var>locals</var> | |
542 | dictionary should not be attempted. Pass an explicit <var>locals</var> | |
543 | dictionary if you need to see effects of the code on <var>locals</var> after | |
544 | function <tt class="function">execfile()</tt> returns. <tt class="function">execfile()</tt> cannot | |
545 | be used reliably to modify a function's locals.</span> | |
546 | </dl> | |
547 | ||
548 | <P> | |
549 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
550 | <td><nobr><b><tt id='l2h-25' xml:id='l2h-25' class="function">file</tt></b>(</nobr></td> | |
551 | <td><var>filename</var><big>[</big><var>, mode</var><big>[</big><var>, bufsize</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
552 | <dd> | |
553 | Return a new file object (described in | |
554 | section <A href="bltin-file-objects.html#bltin-file-objects">2.3.9</A>, ``<a class="ulink" href="bltin-file-objects.html" | |
555 | >File | |
556 | Objects</a>''). | |
557 | The first two arguments are the same as for <code>stdio</code>'s | |
558 | <tt class="cfunction">fopen()</tt>: <var>filename</var> is the file name to be opened, | |
559 | <var>mode</var> indicates how the file is to be opened: <code>'r'</code> for | |
560 | reading, <code>'w'</code> for writing (truncating an existing file), and | |
561 | <code>'a'</code> opens it for appending (which on <em>some</em> <span class="Unix">Unix</span> | |
562 | systems means that <em>all</em> writes append to the end of the file, | |
563 | regardless of the current seek position). | |
564 | ||
565 | <P> | |
566 | Modes <code>'r+'</code>, <code>'w+'</code> and <code>'a+'</code> open the file for | |
567 | updating (note that <code>'w+'</code> truncates the file). Append | |
568 | <code>'b'</code> to the mode to open the file in binary mode, on systems | |
569 | that differentiate between binary and text files (else it is | |
570 | ignored). If the file cannot be opened, <tt class="exception">IOError</tt> is | |
571 | raised. | |
572 | ||
573 | <P> | |
574 | In addition to the standard <tt class="cfunction">fopen()</tt> values <var>mode</var> | |
575 | may be <code>'U'</code> or <code>'rU'</code>. If Python is built with universal | |
576 | newline support (the default) the file is opened as a text file, but | |
577 | lines may be terminated by any of <code>'\n'</code>, the Unix end-of-line | |
578 | convention, | |
579 | <code>'\r'</code>, the Macintosh convention or <code>'\r\n'</code>, the Windows | |
580 | convention. All of these external representations are seen as | |
581 | <code>'\n'</code> | |
582 | by the Python program. If Python is built without universal newline support | |
583 | <var>mode</var> <code>'U'</code> is the same as normal text mode. Note that | |
584 | file objects so opened also have an attribute called | |
585 | <tt class="member">newlines</tt> which has a value of <code>None</code> (if no newlines | |
586 | have yet been seen), <code>'\n'</code>, <code>'\r'</code>, <code>'\r\n'</code>, | |
587 | or a tuple containing all the newline types seen. | |
588 | ||
589 | <P> | |
590 | If <var>mode</var> is omitted, it defaults to <code>'r'</code>. When opening a | |
591 | binary file, you should append <code>'b'</code> to the <var>mode</var> value | |
592 | for improved portability. (It's useful even on systems which don't | |
593 | treat binary and text files differently, where it serves as | |
594 | documentation.) | |
595 | <a id='l2h-83' xml:id='l2h-83'></a> | |
596 | The optional <var>bufsize</var> argument specifies the | |
597 | file's desired buffer size: 0 means unbuffered, 1 means line | |
598 | buffered, any other positive value means use a buffer of | |
599 | (approximately) that size. A negative <var>bufsize</var> means to use | |
600 | the system default, which is usually line buffered for tty | |
601 | devices and fully buffered for other files. If omitted, the system | |
602 | default is used.<A NAME="tex2html3" | |
603 | HREF="#foot1090"><SUP>2.3</SUP></A> | |
604 | <P> | |
605 | The <tt class="function">file()</tt> constructor is new in Python 2.2 and is an | |
606 | alias for <tt class="function">open()</tt>. Both spellings are equivalent. The | |
607 | intent is for <tt class="function">open()</tt> to continue to be preferred for use | |
608 | as a factory function which returns a new <tt class="class">file</tt> object. The | |
609 | spelling, <tt class="class">file</tt> is more suited to type testing (for example, | |
610 | writing "<tt class="samp">isinstance(f, file)</tt>"). | |
611 | </dl> | |
612 | ||
613 | <P> | |
614 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
615 | <td><nobr><b><tt id='l2h-26' xml:id='l2h-26' class="function">filter</tt></b>(</nobr></td> | |
616 | <td><var>function, list</var>)</td></tr></table></dt> | |
617 | <dd> | |
618 | Construct a list from those elements of <var>list</var> for which | |
619 | <var>function</var> returns true. <var>list</var> may be either a sequence, a | |
620 | container which supports iteration, or an iterator, If <var>list</var> | |
621 | is a string or a tuple, the result also has that type; otherwise it | |
622 | is always a list. If <var>function</var> is <code>None</code>, the identity | |
623 | function is assumed, that is, all elements of <var>list</var> that are false | |
624 | (zero or empty) are removed. | |
625 | ||
626 | <P> | |
627 | Note that <code>filter(function, <var>list</var>)</code> is equivalent to | |
628 | <code>[item for item in <var>list</var> if function(item)]</code> if function is | |
629 | not <code>None</code> and <code>[item for item in <var>list</var> if item]</code> if | |
630 | function is <code>None</code>. | |
631 | </dl> | |
632 | ||
633 | <P> | |
634 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
635 | <td><nobr><b><tt id='l2h-27' xml:id='l2h-27' class="function">float</tt></b>(</nobr></td> | |
636 | <td><var></var><big>[</big><var>x</var><big>]</big><var></var>)</td></tr></table></dt> | |
637 | <dd> | |
638 | Convert a string or a number to floating point. If the argument is a | |
639 | string, it must contain a possibly signed decimal or floating point | |
640 | number, possibly embedded in whitespace. Otherwise, the argument may be a plain | |
641 | or long integer or a floating point number, and a floating point | |
642 | number with the same value (within Python's floating point | |
643 | precision) is returned. If no argument is given, returns <code>0.0</code>. | |
644 | ||
645 | <P> | |
646 | <span class="note"><b class="label">Note:</b> | |
647 | When passing in a string, values for NaN<a id='l2h-28' xml:id='l2h-28'></a> | |
648 | and Infinity<a id='l2h-29' xml:id='l2h-29'></a> may be returned, depending on the | |
649 | underlying C library. The specific set of strings accepted which | |
650 | cause these values to be returned depends entirely on the C library | |
651 | and is known to vary.</span> | |
652 | </dl> | |
653 | ||
654 | <P> | |
655 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
656 | <td><nobr><b><tt id='l2h-30' xml:id='l2h-30' class="function">frozenset</tt></b>(</nobr></td> | |
657 | <td><var></var><big>[</big><var>iterable</var><big>]</big><var></var>)</td></tr></table></dt> | |
658 | <dd> | |
659 | Return a frozenset object whose elements are taken from <var>iterable</var>. | |
660 | Frozensets are sets that have no update methods but can be hashed and | |
661 | used as members of other sets or as dictionary keys. The elements of | |
662 | a frozenset must be immutable themselves. To represent sets of sets, | |
663 | the inner sets should also be <tt class="class">frozenset</tt> objects. If | |
664 | <var>iterable</var> is not specified, returns a new empty set, | |
665 | <code>frozenset([])</code>. | |
666 | ||
667 | <span class="versionnote">New in version 2.4.</span> | |
668 | ||
669 | </dl> | |
670 | ||
671 | <P> | |
672 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
673 | <td><nobr><b><tt id='l2h-31' xml:id='l2h-31' class="function">getattr</tt></b>(</nobr></td> | |
674 | <td><var>object, name</var><big>[</big><var>, default</var><big>]</big><var></var>)</td></tr></table></dt> | |
675 | <dd> | |
676 | Return the value of the named attributed of <var>object</var>. <var>name</var> | |
677 | must be a string. If the string is the name of one of the object's | |
678 | attributes, the result is the value of that attribute. For example, | |
679 | <code>getattr(x, 'foobar')</code> is equivalent to <code>x.foobar</code>. If the | |
680 | named attribute does not exist, <var>default</var> is returned if provided, | |
681 | otherwise <tt class="exception">AttributeError</tt> is raised. | |
682 | </dl> | |
683 | ||
684 | <P> | |
685 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
686 | <td><nobr><b><tt id='l2h-32' xml:id='l2h-32' class="function">globals</tt></b>(</nobr></td> | |
687 | <td><var></var>)</td></tr></table></dt> | |
688 | <dd> | |
689 | Return a dictionary representing the current global symbol table. | |
690 | This is always the dictionary of the current module (inside a | |
691 | function or method, this is the module where it is defined, not the | |
692 | module from which it is called). | |
693 | </dl> | |
694 | ||
695 | <P> | |
696 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
697 | <td><nobr><b><tt id='l2h-33' xml:id='l2h-33' class="function">hasattr</tt></b>(</nobr></td> | |
698 | <td><var>object, name</var>)</td></tr></table></dt> | |
699 | <dd> | |
700 | The arguments are an object and a string. The result is <code>True</code> if the | |
701 | string is the name of one of the object's attributes, <code>False</code> if not. | |
702 | (This is implemented by calling <code>getattr(<var>object</var>, | |
703 | <var>name</var>)</code> and seeing whether it raises an exception or not.) | |
704 | </dl> | |
705 | ||
706 | <P> | |
707 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
708 | <td><nobr><b><tt id='l2h-34' xml:id='l2h-34' class="function">hash</tt></b>(</nobr></td> | |
709 | <td><var>object</var>)</td></tr></table></dt> | |
710 | <dd> | |
711 | Return the hash value of the object (if it has one). Hash values | |
712 | are integers. They are used to quickly compare dictionary | |
713 | keys during a dictionary lookup. Numeric values that compare equal | |
714 | have the same hash value (even if they are of different types, as is | |
715 | the case for 1 and 1.0). | |
716 | </dl> | |
717 | ||
718 | <P> | |
719 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
720 | <td><nobr><b><tt id='l2h-35' xml:id='l2h-35' class="function">help</tt></b>(</nobr></td> | |
721 | <td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt> | |
722 | <dd> | |
723 | Invoke the built-in help system. (This function is intended for | |
724 | interactive use.) If no argument is given, the interactive help | |
725 | system starts on the interpreter console. If the argument is a | |
726 | string, then the string is looked up as the name of a module, | |
727 | function, class, method, keyword, or documentation topic, and a | |
728 | help page is printed on the console. If the argument is any other | |
729 | kind of object, a help page on the object is generated. | |
730 | ||
731 | <span class="versionnote">New in version 2.2.</span> | |
732 | ||
733 | </dl> | |
734 | ||
735 | <P> | |
736 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
737 | <td><nobr><b><tt id='l2h-36' xml:id='l2h-36' class="function">hex</tt></b>(</nobr></td> | |
738 | <td><var>x</var>)</td></tr></table></dt> | |
739 | <dd> | |
740 | Convert an integer number (of any size) to a hexadecimal string. | |
741 | The result is a valid Python expression. | |
742 | ||
743 | <span class="versionnote">Changed in version 2.4: | |
744 | Formerly only returned an unsigned literal..</span> | |
745 | ||
746 | </dl> | |
747 | ||
748 | <P> | |
749 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
750 | <td><nobr><b><tt id='l2h-37' xml:id='l2h-37' class="function">id</tt></b>(</nobr></td> | |
751 | <td><var>object</var>)</td></tr></table></dt> | |
752 | <dd> | |
753 | Return the ``identity'' of an object. This is an integer (or long | |
754 | integer) which is guaranteed to be unique and constant for this | |
755 | object during its lifetime. Two objects with non-overlapping lifetimes | |
756 | may have the same <tt class="function">id()</tt> value. (Implementation | |
757 | note: this is the address of the object.) | |
758 | </dl> | |
759 | ||
760 | <P> | |
761 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
762 | <td><nobr><b><tt id='l2h-38' xml:id='l2h-38' class="function">input</tt></b>(</nobr></td> | |
763 | <td><var></var><big>[</big><var>prompt</var><big>]</big><var></var>)</td></tr></table></dt> | |
764 | <dd> | |
765 | Equivalent to <code>eval(raw_input(<var>prompt</var>))</code>. | |
766 | <span class="warning"><b class="label">Warning:</b> | |
767 | This function is not safe from user errors! It | |
768 | expects a valid Python expression as input; if the input is not | |
769 | syntactically valid, a <tt class="exception">SyntaxError</tt> will be raised. | |
770 | Other exceptions may be raised if there is an error during | |
771 | evaluation. (On the other hand, sometimes this is exactly what you | |
772 | need when writing a quick script for expert use.)</span> | |
773 | ||
774 | <P> | |
775 | If the <tt class="module"><a href="module-readline.html">readline</a></tt> module was loaded, then | |
776 | <tt class="function">input()</tt> will use it to provide elaborate line editing and | |
777 | history features. | |
778 | ||
779 | <P> | |
780 | Consider using the <tt class="function">raw_input()</tt> function for general input | |
781 | from users. | |
782 | </dl> | |
783 | ||
784 | <P> | |
785 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
786 | <td><nobr><b><tt id='l2h-39' xml:id='l2h-39' class="function">int</tt></b>(</nobr></td> | |
787 | <td><var></var><big>[</big><var>x</var><big>[</big><var>, radix</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
788 | <dd> | |
789 | Convert a string or number to a plain integer. If the argument is a | |
790 | string, it must contain a possibly signed decimal number | |
791 | representable as a Python integer, possibly embedded in whitespace. | |
792 | The <var>radix</var> parameter gives the base for the | |
793 | conversion and may be any integer in the range [2, 36], or zero. If | |
794 | <var>radix</var> is zero, the proper radix is guessed based on the | |
795 | contents of string; the interpretation is the same as for integer | |
796 | literals. If <var>radix</var> is specified and <var>x</var> is not a string, | |
797 | <tt class="exception">TypeError</tt> is raised. | |
798 | Otherwise, the argument may be a plain or | |
799 | long integer or a floating point number. Conversion of floating | |
800 | point numbers to integers truncates (towards zero). | |
801 | If the argument is outside the integer range a long object will | |
802 | be returned instead. If no arguments are given, returns <code>0</code>. | |
803 | </dl> | |
804 | ||
805 | <P> | |
806 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
807 | <td><nobr><b><tt id='l2h-40' xml:id='l2h-40' class="function">isinstance</tt></b>(</nobr></td> | |
808 | <td><var>object, classinfo</var>)</td></tr></table></dt> | |
809 | <dd> | |
810 | Return true if the <var>object</var> argument is an instance of the | |
811 | <var>classinfo</var> argument, or of a (direct or indirect) subclass | |
812 | thereof. Also return true if <var>classinfo</var> is a type object and | |
813 | <var>object</var> is an object of that type. If <var>object</var> is not a | |
814 | class instance or an object of the given type, the function always | |
815 | returns false. If <var>classinfo</var> is neither a class object nor a | |
816 | type object, it may be a tuple of class or type objects, or may | |
817 | recursively contain other such tuples (other sequence types are not | |
818 | accepted). If <var>classinfo</var> is not a class, type, or tuple of | |
819 | classes, types, and such tuples, a <tt class="exception">TypeError</tt> exception | |
820 | is raised. | |
821 | ||
822 | <span class="versionnote">Changed in version 2.2: | |
823 | Support for a tuple of type information was added.</span> | |
824 | ||
825 | </dl> | |
826 | ||
827 | <P> | |
828 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
829 | <td><nobr><b><tt id='l2h-41' xml:id='l2h-41' class="function">issubclass</tt></b>(</nobr></td> | |
830 | <td><var>class, classinfo</var>)</td></tr></table></dt> | |
831 | <dd> | |
832 | Return true if <var>class</var> is a subclass (direct or indirect) of | |
833 | <var>classinfo</var>. A class is considered a subclass of itself. | |
834 | <var>classinfo</var> may be a tuple of class objects, in which case every | |
835 | entry in <var>classinfo</var> will be checked. In any other case, a | |
836 | <tt class="exception">TypeError</tt> exception is raised. | |
837 | ||
838 | <span class="versionnote">Changed in version 2.3: | |
839 | Support for a tuple of type information was added.</span> | |
840 | ||
841 | </dl> | |
842 | ||
843 | <P> | |
844 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
845 | <td><nobr><b><tt id='l2h-42' xml:id='l2h-42' class="function">iter</tt></b>(</nobr></td> | |
846 | <td><var>o</var><big>[</big><var>, sentinel</var><big>]</big><var></var>)</td></tr></table></dt> | |
847 | <dd> | |
848 | Return an iterator object. The first argument is interpreted very | |
849 | differently depending on the presence of the second argument. | |
850 | Without a second argument, <var>o</var> must be a collection object which | |
851 | supports the iteration protocol (the <tt class="method">__iter__()</tt> method), or | |
852 | it must support the sequence protocol (the <tt class="method">__getitem__()</tt> | |
853 | method with integer arguments starting at <code>0</code>). If it does not | |
854 | support either of those protocols, <tt class="exception">TypeError</tt> is raised. | |
855 | If the second argument, <var>sentinel</var>, is given, then <var>o</var> must | |
856 | be a callable object. The iterator created in this case will call | |
857 | <var>o</var> with no arguments for each call to its <tt class="method">next()</tt> | |
858 | method; if the value returned is equal to <var>sentinel</var>, | |
859 | <tt class="exception">StopIteration</tt> will be raised, otherwise the value will | |
860 | be returned. | |
861 | ||
862 | <span class="versionnote">New in version 2.2.</span> | |
863 | ||
864 | </dl> | |
865 | ||
866 | <P> | |
867 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
868 | <td><nobr><b><tt id='l2h-43' xml:id='l2h-43' class="function">len</tt></b>(</nobr></td> | |
869 | <td><var>s</var>)</td></tr></table></dt> | |
870 | <dd> | |
871 | Return the length (the number of items) of an object. The argument | |
872 | may be a sequence (string, tuple or list) or a mapping (dictionary). | |
873 | </dl> | |
874 | ||
875 | <P> | |
876 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
877 | <td><nobr><b><tt id='l2h-44' xml:id='l2h-44' class="function">list</tt></b>(</nobr></td> | |
878 | <td><var></var><big>[</big><var>sequence</var><big>]</big><var></var>)</td></tr></table></dt> | |
879 | <dd> | |
880 | Return a list whose items are the same and in the same order as | |
881 | <var>sequence</var>'s items. <var>sequence</var> may be either a sequence, a | |
882 | container that supports iteration, or an iterator object. If | |
883 | <var>sequence</var> is already a list, a copy is made and returned, | |
884 | similar to <code><var>sequence</var>[:]</code>. For instance, | |
885 | <code>list('abc')</code> returns <code>['a', 'b', 'c']</code> and <code>list( | |
886 | (1, 2, 3) )</code> returns <code>[1, 2, 3]</code>. If no argument is given, | |
887 | returns a new empty list, <code>[]</code>. | |
888 | </dl> | |
889 | ||
890 | <P> | |
891 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
892 | <td><nobr><b><tt id='l2h-45' xml:id='l2h-45' class="function">locals</tt></b>(</nobr></td> | |
893 | <td><var></var>)</td></tr></table></dt> | |
894 | <dd> | |
895 | Update and return a dictionary representing the current local symbol table. | |
896 | <span class="warning"><b class="label">Warning:</b> | |
897 | The contents of this dictionary should not be modified; | |
898 | changes may not affect the values of local variables used by the | |
899 | interpreter.</span> | |
900 | </dl> | |
901 | ||
902 | <P> | |
903 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
904 | <td><nobr><b><tt id='l2h-46' xml:id='l2h-46' class="function">long</tt></b>(</nobr></td> | |
905 | <td><var></var><big>[</big><var>x</var><big>[</big><var>, radix</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
906 | <dd> | |
907 | Convert a string or number to a long integer. If the argument is a | |
908 | string, it must contain a possibly signed number of | |
909 | arbitrary size, possibly embedded in whitespace. The | |
910 | <var>radix</var> argument is interpreted in the same way as for | |
911 | <tt class="function">int()</tt>, and may only be given when <var>x</var> is a string. | |
912 | Otherwise, the argument may be a plain or | |
913 | long integer or a floating point number, and a long integer with | |
914 | the same value is returned. Conversion of floating | |
915 | point numbers to integers truncates (towards zero). If no arguments | |
916 | are given, returns <code>0L</code>. | |
917 | </dl> | |
918 | ||
919 | <P> | |
920 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
921 | <td><nobr><b><tt id='l2h-47' xml:id='l2h-47' class="function">map</tt></b>(</nobr></td> | |
922 | <td><var>function, list, ...</var>)</td></tr></table></dt> | |
923 | <dd> | |
924 | Apply <var>function</var> to every item of <var>list</var> and return a list | |
925 | of the results. If additional <var>list</var> arguments are passed, | |
926 | <var>function</var> must take that many arguments and is applied to the | |
927 | items of all lists in parallel; if a list is shorter than another it | |
928 | is assumed to be extended with <code>None</code> items. If <var>function</var> | |
929 | is <code>None</code>, the identity function is assumed; if there are | |
930 | multiple list arguments, <tt class="function">map()</tt> returns a list consisting | |
931 | of tuples containing the corresponding items from all lists (a kind | |
932 | of transpose operation). The <var>list</var> arguments may be any kind | |
933 | of sequence; the result is always a list. | |
934 | </dl> | |
935 | ||
936 | <P> | |
937 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
938 | <td><nobr><b><tt id='l2h-48' xml:id='l2h-48' class="function">max</tt></b>(</nobr></td> | |
939 | <td><var>s</var><big>[</big><var>, args...</var><big>]</big><var></var>)</td></tr></table></dt> | |
940 | <dd> | |
941 | With a single argument <var>s</var>, return the largest item of a | |
942 | non-empty sequence (such as a string, tuple or list). With more | |
943 | than one argument, return the largest of the arguments. | |
944 | </dl> | |
945 | ||
946 | <P> | |
947 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
948 | <td><nobr><b><tt id='l2h-49' xml:id='l2h-49' class="function">min</tt></b>(</nobr></td> | |
949 | <td><var>s</var><big>[</big><var>, args...</var><big>]</big><var></var>)</td></tr></table></dt> | |
950 | <dd> | |
951 | With a single argument <var>s</var>, return the smallest item of a | |
952 | non-empty sequence (such as a string, tuple or list). With more | |
953 | than one argument, return the smallest of the arguments. | |
954 | </dl> | |
955 | ||
956 | <P> | |
957 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
958 | <td><nobr><b><tt id='l2h-50' xml:id='l2h-50' class="function">object</tt></b>(</nobr></td> | |
959 | <td><var></var>)</td></tr></table></dt> | |
960 | <dd> | |
961 | Return a new featureless object. <tt class="function">object()</tt> is a base | |
962 | for all new style classes. It has the methods that are common | |
963 | to all instances of new style classes. | |
964 | ||
965 | <span class="versionnote">New in version 2.2.</span> | |
966 | ||
967 | <P> | |
968 | ||
969 | <span class="versionnote">Changed in version 2.3: | |
970 | This function does not accept any arguments. | |
971 | Formerly, it accepted arguments but ignored them.</span> | |
972 | ||
973 | </dl> | |
974 | ||
975 | <P> | |
976 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
977 | <td><nobr><b><tt id='l2h-51' xml:id='l2h-51' class="function">oct</tt></b>(</nobr></td> | |
978 | <td><var>x</var>)</td></tr></table></dt> | |
979 | <dd> | |
980 | Convert an integer number (of any size) to an octal string. The | |
981 | result is a valid Python expression. | |
982 | ||
983 | <span class="versionnote">Changed in version 2.4: | |
984 | Formerly only returned an unsigned literal..</span> | |
985 | ||
986 | </dl> | |
987 | ||
988 | <P> | |
989 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
990 | <td><nobr><b><tt id='l2h-52' xml:id='l2h-52' class="function">open</tt></b>(</nobr></td> | |
991 | <td><var>filename</var><big>[</big><var>, mode</var><big>[</big><var>, bufsize</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
992 | <dd> | |
993 | An alias for the <tt class="function">file()</tt> function above. | |
994 | </dl> | |
995 | ||
996 | <P> | |
997 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
998 | <td><nobr><b><tt id='l2h-53' xml:id='l2h-53' class="function">ord</tt></b>(</nobr></td> | |
999 | <td><var>c</var>)</td></tr></table></dt> | |
1000 | <dd> | |
1001 | Given a string of length one, return an integer representing the | |
1002 | Unicode code point of the character when the argument is a unicode object, | |
1003 | or the value of the byte when the argument is an 8-bit string. | |
1004 | For example, <code>ord('a')</code> returns the integer <code>97</code>, | |
1005 | <code>ord(u'\u2020')</code> returns <code>8224</code>. This is the inverse of | |
1006 | <tt class="function">chr()</tt> for 8-bit strings and of <tt class="function">unichr()</tt> for unicode | |
1007 | objects. If a unicode argument is given and Python was built with | |
1008 | UCS2 Unicode, then the character's code point must be in the range | |
1009 | [0..65535] inclusive; otherwise the string length is two, and a | |
1010 | <tt class="exception">TypeError</tt> will be raised. | |
1011 | </dl> | |
1012 | ||
1013 | <P> | |
1014 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1015 | <td><nobr><b><tt id='l2h-54' xml:id='l2h-54' class="function">pow</tt></b>(</nobr></td> | |
1016 | <td><var>x, y</var><big>[</big><var>, z</var><big>]</big><var></var>)</td></tr></table></dt> | |
1017 | <dd> | |
1018 | Return <var>x</var> to the power <var>y</var>; if <var>z</var> is present, return | |
1019 | <var>x</var> to the power <var>y</var>, modulo <var>z</var> (computed more | |
1020 | efficiently than <code>pow(<var>x</var>, <var>y</var>) % <var>z</var></code>). The | |
1021 | arguments must have numeric types. With mixed operand types, the | |
1022 | coercion rules for binary arithmetic operators apply. For int and | |
1023 | long int operands, the result has the same type as the operands | |
1024 | (after coercion) unless the second argument is negative; in that | |
1025 | case, all arguments are converted to float and a float result is | |
1026 | delivered. For example, <code>10**2</code> returns <code>100</code>, but | |
1027 | <code>10**-2</code> returns <code>0.01</code>. (This last feature was added in | |
1028 | Python 2.2. In Python 2.1 and before, if both arguments were of integer | |
1029 | types and the second argument was negative, an exception was raised.) | |
1030 | If the second argument is negative, the third argument must be omitted. | |
1031 | If <var>z</var> is present, <var>x</var> and <var>y</var> must be of integer types, | |
1032 | and <var>y</var> must be non-negative. (This restriction was added in | |
1033 | Python 2.2. In Python 2.1 and before, floating 3-argument <code>pow()</code> | |
1034 | returned platform-dependent results depending on floating-point | |
1035 | rounding accidents.) | |
1036 | </dl> | |
1037 | ||
1038 | <P> | |
1039 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1040 | <td><nobr><b><tt id='l2h-55' xml:id='l2h-55' class="function">property</tt></b>(</nobr></td> | |
1041 | <td><var></var><big>[</big><var>fget</var><big>[</big><var>, fset</var><big>[</big><var>, | |
1042 | fdel</var><big>[</big><var>, doc</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
1043 | <dd> | |
1044 | Return a property attribute for new-style classes (classes that | |
1045 | derive from <tt class="class">object</tt>). | |
1046 | ||
1047 | <P> | |
1048 | <var>fget</var> is a function for getting an attribute value, likewise | |
1049 | <var>fset</var> is a function for setting, and <var>fdel</var> a function | |
1050 | for del'ing, an attribute. Typical use is to define a managed attribute x: | |
1051 | ||
1052 | <P> | |
1053 | <div class="verbatim"><pre> | |
1054 | class C(object): | |
1055 | def __init__(self): self.__x = None | |
1056 | def getx(self): return self.__x | |
1057 | def setx(self, value): self.__x = value | |
1058 | def delx(self): del self.__x | |
1059 | x = property(getx, setx, delx, "I'm the 'x' property.") | |
1060 | </pre></div> | |
1061 | ||
1062 | <P> | |
1063 | ||
1064 | <span class="versionnote">New in version 2.2.</span> | |
1065 | ||
1066 | </dl> | |
1067 | ||
1068 | <P> | |
1069 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1070 | <td><nobr><b><tt id='l2h-56' xml:id='l2h-56' class="function">range</tt></b>(</nobr></td> | |
1071 | <td><var></var><big>[</big><var>start,</var><big>]</big><var> stop</var><big>[</big><var>, step</var><big>]</big><var></var>)</td></tr></table></dt> | |
1072 | <dd> | |
1073 | This is a versatile function to create lists containing arithmetic | |
1074 | progressions. It is most often used in <tt class="keyword">for</tt> loops. The | |
1075 | arguments must be plain integers. If the <var>step</var> argument is | |
1076 | omitted, it defaults to <code>1</code>. If the <var>start</var> argument is | |
1077 | omitted, it defaults to <code>0</code>. The full form returns a list of | |
1078 | plain integers <code>[<var>start</var>, <var>start</var> + <var>step</var>, | |
1079 | <var>start</var> + 2 * <var>step</var>, ...]</code>. If <var>step</var> is positive, | |
1080 | the last element is the largest <code><var>start</var> + <var>i</var> * | |
1081 | <var>step</var></code> less than <var>stop</var>; if <var>step</var> is negative, the last | |
1082 | element is the smallest <code><var>start</var> + <var>i</var> * <var>step</var></code> | |
1083 | greater than <var>stop</var>. <var>step</var> must not be zero (or else | |
1084 | <tt class="exception">ValueError</tt> is raised). Example: | |
1085 | ||
1086 | <P> | |
1087 | <div class="verbatim"><pre> | |
1088 | >>> range(10) | |
1089 | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
1090 | >>> range(1, 11) | |
1091 | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
1092 | >>> range(0, 30, 5) | |
1093 | [0, 5, 10, 15, 20, 25] | |
1094 | >>> range(0, 10, 3) | |
1095 | [0, 3, 6, 9] | |
1096 | >>> range(0, -10, -1) | |
1097 | [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] | |
1098 | >>> range(0) | |
1099 | [] | |
1100 | >>> range(1, 0) | |
1101 | [] | |
1102 | </pre></div> | |
1103 | </dl> | |
1104 | ||
1105 | <P> | |
1106 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1107 | <td><nobr><b><tt id='l2h-57' xml:id='l2h-57' class="function">raw_input</tt></b>(</nobr></td> | |
1108 | <td><var></var><big>[</big><var>prompt</var><big>]</big><var></var>)</td></tr></table></dt> | |
1109 | <dd> | |
1110 | If the <var>prompt</var> argument is present, it is written to standard output | |
1111 | without a trailing newline. The function then reads a line from input, | |
1112 | converts it to a string (stripping a trailing newline), and returns that. | |
1113 | When EOF is read, <tt class="exception">EOFError</tt> is raised. Example: | |
1114 | ||
1115 | <P> | |
1116 | <div class="verbatim"><pre> | |
1117 | >>> s = raw_input('--> ') | |
1118 | --> Monty Python's Flying Circus | |
1119 | >>> s | |
1120 | "Monty Python's Flying Circus" | |
1121 | </pre></div> | |
1122 | ||
1123 | <P> | |
1124 | If the <tt class="module"><a href="module-readline.html">readline</a></tt> module was loaded, then | |
1125 | <tt class="function">raw_input()</tt> will use it to provide elaborate | |
1126 | line editing and history features. | |
1127 | </dl> | |
1128 | ||
1129 | <P> | |
1130 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1131 | <td><nobr><b><tt id='l2h-58' xml:id='l2h-58' class="function">reduce</tt></b>(</nobr></td> | |
1132 | <td><var>function, sequence</var><big>[</big><var>, initializer</var><big>]</big><var></var>)</td></tr></table></dt> | |
1133 | <dd> | |
1134 | Apply <var>function</var> of two arguments cumulatively to the items of | |
1135 | <var>sequence</var>, from left to right, so as to reduce the sequence to | |
1136 | a single value. For example, <code>reduce(lambda x, y: x+y, [1, 2, | |
1137 | 3, 4, 5])</code> calculates <code>((((1+2)+3)+4)+5)</code>. The left argument, | |
1138 | <var>x</var>, is the accumulated value and the right argument, <var>y</var>, | |
1139 | is the update value from the <var>sequence</var>. If the optional | |
1140 | <var>initializer</var> is present, it is placed before the items of the | |
1141 | sequence in the calculation, and serves as a default when the | |
1142 | sequence is empty. If <var>initializer</var> is not given and | |
1143 | <var>sequence</var> contains only one item, the first item is returned. | |
1144 | </dl> | |
1145 | ||
1146 | <P> | |
1147 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1148 | <td><nobr><b><tt id='l2h-59' xml:id='l2h-59' class="function">reload</tt></b>(</nobr></td> | |
1149 | <td><var>module</var>)</td></tr></table></dt> | |
1150 | <dd> | |
1151 | Reload a previously imported <var>module</var>. The | |
1152 | argument must be a module object, so it must have been successfully | |
1153 | imported before. This is useful if you have edited the module | |
1154 | source file using an external editor and want to try out the new | |
1155 | version without leaving the Python interpreter. The return value is | |
1156 | the module object (the same as the <var>module</var> argument). | |
1157 | ||
1158 | <P> | |
1159 | When <code>reload(module)</code> is executed: | |
1160 | ||
1161 | <P> | |
1162 | ||
1163 | <UL> | |
1164 | <LI>Python modules' code is recompiled and the module-level code | |
1165 | reexecuted, defining a new set of objects which are bound to names in | |
1166 | the module's dictionary. The <code>init</code> function of extension | |
1167 | modules is not called a second time. | |
1168 | ||
1169 | <P> | |
1170 | </LI> | |
1171 | <LI>As with all other objects in Python the old objects are only | |
1172 | reclaimed after their reference counts drop to zero. | |
1173 | ||
1174 | <P> | |
1175 | </LI> | |
1176 | <LI>The names in the module namespace are updated to point to | |
1177 | any new or changed objects. | |
1178 | ||
1179 | <P> | |
1180 | </LI> | |
1181 | <LI>Other references to the old objects (such as names external | |
1182 | to the module) are not rebound to refer to the new objects and | |
1183 | must be updated in each namespace where they occur if that is | |
1184 | desired. | |
1185 | ||
1186 | <P> | |
1187 | </LI> | |
1188 | </UL> | |
1189 | ||
1190 | <P> | |
1191 | There are a number of other caveats: | |
1192 | ||
1193 | <P> | |
1194 | If a module is syntactically correct but its initialization fails, | |
1195 | the first <tt class="keyword">import</tt> statement for it does not bind its name | |
1196 | locally, but does store a (partially initialized) module object in | |
1197 | <code>sys.modules</code>. To reload the module you must first | |
1198 | <tt class="keyword">import</tt> it again (this will bind the name to the partially | |
1199 | initialized module object) before you can <tt class="function">reload()</tt> it. | |
1200 | ||
1201 | <P> | |
1202 | When a module is reloaded, its dictionary (containing the module's | |
1203 | global variables) is retained. Redefinitions of names will override | |
1204 | the old definitions, so this is generally not a problem. If the new | |
1205 | version of a module does not define a name that was defined by the | |
1206 | old version, the old definition remains. This feature can be used | |
1207 | to the module's advantage if it maintains a global table or cache of | |
1208 | objects -- with a <tt class="keyword">try</tt> statement it can test for the | |
1209 | table's presence and skip its initialization if desired: | |
1210 | ||
1211 | <P> | |
1212 | <div class="verbatim"><pre> | |
1213 | try: | |
1214 | cache | |
1215 | except NameError: | |
1216 | cache = {} | |
1217 | </pre></div> | |
1218 | ||
1219 | <P> | |
1220 | It is legal though generally not very useful to reload built-in or | |
1221 | dynamically loaded modules, except for <tt class="module"><a href="module-sys.html">sys</a></tt>, | |
1222 | <tt class="module"><a href="module-main.html">__main__</a></tt> and <tt class="module"><a href="module-builtin.html">__builtin__</a></tt>. In | |
1223 | many cases, however, extension modules are not designed to be | |
1224 | initialized more than once, and may fail in arbitrary ways when | |
1225 | reloaded. | |
1226 | ||
1227 | <P> | |
1228 | If a module imports objects from another module using <tt class="keyword">from</tt> | |
1229 | ... <tt class="keyword">import</tt> ..., calling <tt class="function">reload()</tt> for | |
1230 | the other module does not redefine the objects imported from it -- | |
1231 | one way around this is to re-execute the <tt class="keyword">from</tt> statement, | |
1232 | another is to use <tt class="keyword">import</tt> and qualified names | |
1233 | (<var>module</var>.<var>name</var>) instead. | |
1234 | ||
1235 | <P> | |
1236 | If a module instantiates instances of a class, reloading the module | |
1237 | that defines the class does not affect the method definitions of the | |
1238 | instances -- they continue to use the old class definition. The | |
1239 | same is true for derived classes. | |
1240 | </dl> | |
1241 | ||
1242 | <P> | |
1243 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1244 | <td><nobr><b><tt id='l2h-60' xml:id='l2h-60' class="function">repr</tt></b>(</nobr></td> | |
1245 | <td><var>object</var>)</td></tr></table></dt> | |
1246 | <dd> | |
1247 | Return a string containing a printable representation of an object. | |
1248 | This is the same value yielded by conversions (reverse quotes). | |
1249 | It is sometimes useful to be able to access this operation as an | |
1250 | ordinary function. For many types, this function makes an attempt | |
1251 | to return a string that would yield an object with the same value | |
1252 | when passed to <tt class="function">eval()</tt>. | |
1253 | </dl> | |
1254 | ||
1255 | <P> | |
1256 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1257 | <td><nobr><b><tt id='l2h-61' xml:id='l2h-61' class="function">reversed</tt></b>(</nobr></td> | |
1258 | <td><var>seq</var>)</td></tr></table></dt> | |
1259 | <dd> | |
1260 | Return a reverse iterator. <var>seq</var> must be an object which | |
1261 | supports the sequence protocol (the __len__() method and the | |
1262 | <tt class="method">__getitem__()</tt> method with integer arguments starting at | |
1263 | <code>0</code>). | |
1264 | ||
1265 | <span class="versionnote">New in version 2.4.</span> | |
1266 | ||
1267 | </dl> | |
1268 | ||
1269 | <P> | |
1270 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1271 | <td><nobr><b><tt id='l2h-62' xml:id='l2h-62' class="function">round</tt></b>(</nobr></td> | |
1272 | <td><var>x</var><big>[</big><var>, n</var><big>]</big><var></var>)</td></tr></table></dt> | |
1273 | <dd> | |
1274 | Return the floating point value <var>x</var> rounded to <var>n</var> digits | |
1275 | after the decimal point. If <var>n</var> is omitted, it defaults to zero. | |
1276 | The result is a floating point number. Values are rounded to the | |
1277 | closest multiple of 10 to the power minus <var>n</var>; if two multiples | |
1278 | are equally close, rounding is done away from 0 (so. for example, | |
1279 | <code>round(0.5)</code> is <code>1.0</code> and <code>round(-0.5)</code> is <code>-1.0</code>). | |
1280 | </dl> | |
1281 | ||
1282 | <P> | |
1283 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1284 | <td><nobr><b><tt id='l2h-63' xml:id='l2h-63' class="function">set</tt></b>(</nobr></td> | |
1285 | <td><var></var><big>[</big><var>iterable</var><big>]</big><var></var>)</td></tr></table></dt> | |
1286 | <dd> | |
1287 | Return a set whose elements are taken from <var>iterable</var>. The elements | |
1288 | must be immutable. To represent sets of sets, the inner sets should | |
1289 | be <tt class="class">frozenset</tt> objects. If <var>iterable</var> is not specified, | |
1290 | returns a new empty set, <code>set([])</code>. | |
1291 | ||
1292 | <span class="versionnote">New in version 2.4.</span> | |
1293 | ||
1294 | </dl> | |
1295 | ||
1296 | <P> | |
1297 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1298 | <td><nobr><b><tt id='l2h-64' xml:id='l2h-64' class="function">setattr</tt></b>(</nobr></td> | |
1299 | <td><var>object, name, value</var>)</td></tr></table></dt> | |
1300 | <dd> | |
1301 | This is the counterpart of <tt class="function">getattr()</tt>. The arguments are an | |
1302 | object, a string and an arbitrary value. The string may name an | |
1303 | existing attribute or a new attribute. The function assigns the | |
1304 | value to the attribute, provided the object allows it. For example, | |
1305 | <code>setattr(<var>x</var>, '<var>foobar</var>', 123)</code> is equivalent to | |
1306 | <code><var>x</var>.<var>foobar</var> = 123</code>. | |
1307 | </dl> | |
1308 | ||
1309 | <P> | |
1310 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1311 | <td><nobr><b><tt id='l2h-65' xml:id='l2h-65' class="function">slice</tt></b>(</nobr></td> | |
1312 | <td><var></var><big>[</big><var>start,</var><big>]</big><var> stop</var><big>[</big><var>, step</var><big>]</big><var></var>)</td></tr></table></dt> | |
1313 | <dd> | |
1314 | Return a slice object representing the set of indices specified by | |
1315 | <code>range(<var>start</var>, <var>stop</var>, <var>step</var>)</code>. The <var>start</var> | |
1316 | and <var>step</var> arguments default to <code>None</code>. Slice objects have | |
1317 | read-only data attributes <tt class="member">start</tt>, <tt class="member">stop</tt> and | |
1318 | <tt class="member">step</tt> which merely return the argument values (or their | |
1319 | default). They have no other explicit functionality; however they | |
1320 | are used by Numerical Python<a id='l2h-84' xml:id='l2h-84'></a> and other third | |
1321 | party extensions. Slice objects are also generated when extended | |
1322 | indexing syntax is used. For example: "<tt class="samp">a[start:stop:step]</tt>" or | |
1323 | "<tt class="samp">a[start:stop, i]</tt>". | |
1324 | </dl> | |
1325 | ||
1326 | <P> | |
1327 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1328 | <td><nobr><b><tt id='l2h-66' xml:id='l2h-66' class="function">sorted</tt></b>(</nobr></td> | |
1329 | <td><var>iterable</var><big>[</big><var>, cmp</var><big>[</big><var>, | |
1330 | key</var><big>[</big><var>, reverse</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
1331 | <dd> | |
1332 | Return a new sorted list from the items in <var>iterable</var>. | |
1333 | The optional arguments <var>cmp</var>, <var>key</var>, and <var>reverse</var> | |
1334 | have the same meaning as those for the <tt class="method">list.sort()</tt> method. | |
1335 | ||
1336 | <span class="versionnote">New in version 2.4.</span> | |
1337 | ||
1338 | </dl> | |
1339 | ||
1340 | <P> | |
1341 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1342 | <td><nobr><b><tt id='l2h-67' xml:id='l2h-67' class="function">staticmethod</tt></b>(</nobr></td> | |
1343 | <td><var>function</var>)</td></tr></table></dt> | |
1344 | <dd> | |
1345 | Return a static method for <var>function</var>. | |
1346 | ||
1347 | <P> | |
1348 | A static method does not receive an implicit first argument. | |
1349 | To declare a static method, use this idiom: | |
1350 | ||
1351 | <P> | |
1352 | <div class="verbatim"><pre> | |
1353 | class C: | |
1354 | @staticmethod | |
1355 | def f(arg1, arg2, ...): ... | |
1356 | </pre></div> | |
1357 | ||
1358 | <P> | |
1359 | The <code>@staticmethod</code> form is a function decorator - see the description | |
1360 | of function definitions in chapter 7 of the | |
1361 | <em class="citetitle"><a | |
1362 | href="../ref/ref.html" | |
1363 | title="Python Reference Manual" | |
1364 | >Python Reference Manual</a></em> for details. | |
1365 | ||
1366 | <P> | |
1367 | It can be called either on the class (such as <code>C.f()</code>) or on an | |
1368 | instance (such as <code>C().f()</code>). The instance is ignored except | |
1369 | for its class. | |
1370 | ||
1371 | <P> | |
1372 | Static methods in Python are similar to those found in Java or C++. | |
1373 | For a more advanced concept, see <tt class="function">classmethod()</tt> in this | |
1374 | section. | |
1375 | ||
1376 | <span class="versionnote">New in version 2.2.</span> | |
1377 | ||
1378 | <span class="versionnote">Changed in version 2.4: | |
1379 | Function decorator syntax added.</span> | |
1380 | ||
1381 | </dl> | |
1382 | ||
1383 | <P> | |
1384 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1385 | <td><nobr><b><tt id='l2h-68' xml:id='l2h-68' class="function">str</tt></b>(</nobr></td> | |
1386 | <td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt> | |
1387 | <dd> | |
1388 | Return a string containing a nicely printable representation of an | |
1389 | object. For strings, this returns the string itself. The | |
1390 | difference with <code>repr(<var>object</var>)</code> is that | |
1391 | <code>str(<var>object</var>)</code> does not always attempt to return a string | |
1392 | that is acceptable to <tt class="function">eval()</tt>; its goal is to return a | |
1393 | printable string. If no argument is given, returns the empty | |
1394 | string, <code>''</code>. | |
1395 | </dl> | |
1396 | ||
1397 | <P> | |
1398 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1399 | <td><nobr><b><tt id='l2h-69' xml:id='l2h-69' class="function">sum</tt></b>(</nobr></td> | |
1400 | <td><var>sequence</var><big>[</big><var>, start</var><big>]</big><var></var>)</td></tr></table></dt> | |
1401 | <dd> | |
1402 | Sums <var>start</var> and the items of a <var>sequence</var>, from left to | |
1403 | right, and returns the total. <var>start</var> defaults to <code>0</code>. | |
1404 | The <var>sequence</var>'s items are normally numbers, and are not allowed | |
1405 | to be strings. The fast, correct way to concatenate sequence of | |
1406 | strings is by calling <code>''.join(<var>sequence</var>)</code>. | |
1407 | Note that <code>sum(range(<var>n</var>), <var>m</var>)</code> is equivalent to | |
1408 | <code>reduce(operator.add, range(<var>n</var>), <var>m</var>)</code> | |
1409 | ||
1410 | <span class="versionnote">New in version 2.3.</span> | |
1411 | ||
1412 | </dl> | |
1413 | ||
1414 | <P> | |
1415 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1416 | <td><nobr><b><tt id='l2h-70' xml:id='l2h-70' class="function">super</tt></b>(</nobr></td> | |
1417 | <td><var>type</var><big>[</big><var>, object-or-type</var><big>]</big><var></var>)</td></tr></table></dt> | |
1418 | <dd> | |
1419 | Return the superclass of <var>type</var>. If the second argument is omitted | |
1420 | the super object returned is unbound. If the second argument is an | |
1421 | object, <code>isinstance(<var>obj</var>, <var>type</var>)</code> must be true. If | |
1422 | the second argument is a type, <code>issubclass(<var>type2</var>, | |
1423 | <var>type</var>)</code> must be true. | |
1424 | <tt class="function">super()</tt> only works for new-style classes. | |
1425 | ||
1426 | <P> | |
1427 | A typical use for calling a cooperative superclass method is: | |
1428 | <div class="verbatim"><pre> | |
1429 | class C(B): | |
1430 | def meth(self, arg): | |
1431 | super(C, self).meth(arg) | |
1432 | </pre></div> | |
1433 | ||
1434 | <P> | |
1435 | Note that <tt class="function">super</tt> is implemented as part of the binding process for | |
1436 | explicit dotted attribute lookups such as | |
1437 | "<tt class="samp">super(C, self).__getitem__(name)</tt>". Accordingly, <tt class="function">super</tt> is | |
1438 | undefined for implicit lookups using statements or operators such as | |
1439 | "<tt class="samp">super(C, self)[name]</tt>". | |
1440 | ||
1441 | <span class="versionnote">New in version 2.2.</span> | |
1442 | ||
1443 | </dl> | |
1444 | ||
1445 | <P> | |
1446 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1447 | <td><nobr><b><tt id='l2h-71' xml:id='l2h-71' class="function">tuple</tt></b>(</nobr></td> | |
1448 | <td><var></var><big>[</big><var>sequence</var><big>]</big><var></var>)</td></tr></table></dt> | |
1449 | <dd> | |
1450 | Return a tuple whose items are the same and in the same order as | |
1451 | <var>sequence</var>'s items. <var>sequence</var> may be a sequence, a | |
1452 | container that supports iteration, or an iterator object. | |
1453 | If <var>sequence</var> is already a tuple, it | |
1454 | is returned unchanged. For instance, <code>tuple('abc')</code> returns | |
1455 | <code>('a', 'b', 'c')</code> and <code>tuple([1, 2, 3])</code> returns | |
1456 | <code>(1, 2, 3)</code>. If no argument is given, returns a new empty | |
1457 | tuple, <code>()</code>. | |
1458 | </dl> | |
1459 | ||
1460 | <P> | |
1461 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1462 | <td><nobr><b><tt id='l2h-72' xml:id='l2h-72' class="function">type</tt></b>(</nobr></td> | |
1463 | <td><var>object</var>)</td></tr></table></dt> | |
1464 | <dd> | |
1465 | Return the type of an <var>object</var>. The return value is a | |
1466 | type<a id='l2h-73' xml:id='l2h-73'></a> object. The <tt class="function">isinstance()</tt> built-in | |
1467 | function is recommended for testing the type of an object. | |
1468 | ||
1469 | <P> | |
1470 | With three arguments, <tt class="function">type</tt> functions as a constructor | |
1471 | as detailed below. | |
1472 | </dl> | |
1473 | ||
1474 | <P> | |
1475 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1476 | <td><nobr><b><tt id='l2h-74' xml:id='l2h-74' class="function">type</tt></b>(</nobr></td> | |
1477 | <td><var>name, bases, dict</var>)</td></tr></table></dt> | |
1478 | <dd> | |
1479 | Return a new type object. This is essentially a dynamic form of the | |
1480 | <tt class="keyword">class</tt> statement. The <var>name</var> string is the class name | |
1481 | and becomes the <tt class="member">__name__</tt> attribute; the <var>bases</var> tuple | |
1482 | itemizes the base classes and becomes the <tt class="member">__bases__</tt> | |
1483 | attribute; and the <var>dict</var> dictionary is the namespace containing | |
1484 | definitions for class body and becomes the <tt class="member">__dict__</tt> | |
1485 | attribute. For example, the following two statements create | |
1486 | identical <tt class="class">type</tt> objects: | |
1487 | ||
1488 | <P> | |
1489 | <div class="verbatim"><pre> | |
1490 | >>> class X(object): | |
1491 | ... a = 1 | |
1492 | ... | |
1493 | >>> X = type('X', (object,), dict(a=1)) | |
1494 | </pre></div> | |
1495 | ||
1496 | <span class="versionnote">New in version 2.2.</span> | |
1497 | ||
1498 | </dl> | |
1499 | ||
1500 | <P> | |
1501 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1502 | <td><nobr><b><tt id='l2h-75' xml:id='l2h-75' class="function">unichr</tt></b>(</nobr></td> | |
1503 | <td><var>i</var>)</td></tr></table></dt> | |
1504 | <dd> | |
1505 | Return the Unicode string of one character whose Unicode code is the | |
1506 | integer <var>i</var>. For example, <code>unichr(97)</code> returns the string | |
1507 | <code>u'a'</code>. This is the inverse of <tt class="function">ord()</tt> for Unicode | |
1508 | strings. The valid range for the argument depends how Python was | |
1509 | configured - it may be either UCS2 [0..0xFFFF] or UCS4 [0..0x10FFFF]. | |
1510 | <tt class="exception">ValueError</tt> is raised otherwise. | |
1511 | ||
1512 | <span class="versionnote">New in version 2.0.</span> | |
1513 | ||
1514 | </dl> | |
1515 | ||
1516 | <P> | |
1517 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1518 | <td><nobr><b><tt id='l2h-76' xml:id='l2h-76' class="function">unicode</tt></b>(</nobr></td> | |
1519 | <td><var></var><big>[</big><var>object</var><big>[</big><var>, encoding | |
1520 | </var><big>[</big><var>, errors</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
1521 | <dd> | |
1522 | Return the Unicode string version of <var>object</var> using one of the | |
1523 | following modes: | |
1524 | ||
1525 | <P> | |
1526 | If <var>encoding</var> and/or <var>errors</var> are given, <code>unicode()</code> | |
1527 | will decode the object which can either be an 8-bit string or a | |
1528 | character buffer using the codec for <var>encoding</var>. The | |
1529 | <var>encoding</var> parameter is a string giving the name of an encoding; | |
1530 | if the encoding is not known, <tt class="exception">LookupError</tt> is raised. | |
1531 | Error handling is done according to <var>errors</var>; this specifies the | |
1532 | treatment of characters which are invalid in the input encoding. If | |
1533 | <var>errors</var> is <code>'strict'</code> (the default), a | |
1534 | <tt class="exception">ValueError</tt> is raised on errors, while a value of | |
1535 | <code>'ignore'</code> causes errors to be silently ignored, and a value of | |
1536 | <code>'replace'</code> causes the official Unicode replacement character, | |
1537 | <code>U+FFFD</code>, to be used to replace input characters which cannot | |
1538 | be decoded. See also the <tt class="module"><a href="module-codecs.html">codecs</a></tt> module. | |
1539 | ||
1540 | <P> | |
1541 | If no optional parameters are given, <code>unicode()</code> will mimic the | |
1542 | behaviour of <code>str()</code> except that it returns Unicode strings | |
1543 | instead of 8-bit strings. More precisely, if <var>object</var> is a | |
1544 | Unicode string or subclass it will return that Unicode string without | |
1545 | any additional decoding applied. | |
1546 | ||
1547 | <P> | |
1548 | For objects which provide a <tt class="method">__unicode__()</tt> method, it will | |
1549 | call this method without arguments to create a Unicode string. For | |
1550 | all other objects, the 8-bit string version or representation is | |
1551 | requested and then converted to a Unicode string using the codec for | |
1552 | the default encoding in <code>'strict'</code> mode. | |
1553 | ||
1554 | <P> | |
1555 | ||
1556 | <span class="versionnote">New in version 2.0.</span> | |
1557 | ||
1558 | <span class="versionnote">Changed in version 2.2: | |
1559 | Support for <tt class="method">__unicode__()</tt> added.</span> | |
1560 | ||
1561 | </dl> | |
1562 | ||
1563 | <P> | |
1564 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1565 | <td><nobr><b><tt id='l2h-77' xml:id='l2h-77' class="function">vars</tt></b>(</nobr></td> | |
1566 | <td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt> | |
1567 | <dd> | |
1568 | Without arguments, return a dictionary corresponding to the current | |
1569 | local symbol table. With a module, class or class instance object | |
1570 | as argument (or anything else that has a <tt class="member">__dict__</tt> | |
1571 | attribute), returns a dictionary corresponding to the object's | |
1572 | symbol table. The returned dictionary should not be modified: the | |
1573 | effects on the corresponding symbol table are undefined.<A NAME="tex2html4" | |
1574 | HREF="#foot996"><SUP>2.4</SUP></A></dl> | |
1575 | ||
1576 | <P> | |
1577 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1578 | <td><nobr><b><tt id='l2h-78' xml:id='l2h-78' class="function">xrange</tt></b>(</nobr></td> | |
1579 | <td><var></var><big>[</big><var>start,</var><big>]</big><var> stop</var><big>[</big><var>, step</var><big>]</big><var></var>)</td></tr></table></dt> | |
1580 | <dd> | |
1581 | This function is very similar to <tt class="function">range()</tt>, but returns an | |
1582 | ``xrange object'' instead of a list. This is an opaque sequence | |
1583 | type which yields the same values as the corresponding list, without | |
1584 | actually storing them all simultaneously. The advantage of | |
1585 | <tt class="function">xrange()</tt> over <tt class="function">range()</tt> is minimal (since | |
1586 | <tt class="function">xrange()</tt> still has to create the values when asked for | |
1587 | them) except when a very large range is used on a memory-starved | |
1588 | machine or when all of the range's elements are never used (such as | |
1589 | when the loop is usually terminated with <tt class="keyword">break</tt>). | |
1590 | ||
1591 | <P> | |
1592 | <span class="note"><b class="label">Note:</b> | |
1593 | <tt class="function">xrange()</tt> is intended to be simple and fast. | |
1594 | Implementations may impose restrictions to achieve this. | |
1595 | The C implementation of Python restricts all arguments to | |
1596 | native C longs ("short" Python integers), and also requires | |
1597 | that the number of elements fit in a native C long.</span> | |
1598 | </dl> | |
1599 | ||
1600 | <P> | |
1601 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
1602 | <td><nobr><b><tt id='l2h-79' xml:id='l2h-79' class="function">zip</tt></b>(</nobr></td> | |
1603 | <td><var></var><big>[</big><var>iterable, ...</var><big>]</big><var></var>)</td></tr></table></dt> | |
1604 | <dd> | |
1605 | This function returns a list of tuples, where the <var>i</var>-th tuple contains | |
1606 | the <var>i</var>-th element from each of the argument sequences or iterables. | |
1607 | The returned list is truncated in length to the length of | |
1608 | the shortest argument sequence. When there are multiple arguments | |
1609 | which are all of the same length, <tt class="function">zip()</tt> is | |
1610 | similar to <tt class="function">map()</tt> with an initial argument of <code>None</code>. | |
1611 | With a single sequence argument, it returns a list of 1-tuples. | |
1612 | With no arguments, it returns an empty list. | |
1613 | ||
1614 | <span class="versionnote">New in version 2.0.</span> | |
1615 | ||
1616 | <P> | |
1617 | ||
1618 | <span class="versionnote">Changed in version 2.4: | |
1619 | Formerly, <tt class="function">zip()</tt> required at least one argument | |
1620 | and <code>zip()</code> raised a <tt class="exception">TypeError</tt> instead of returning | |
1621 | an empty list..</span> | |
1622 | ||
1623 | </dl> | |
1624 | ||
1625 | <P> | |
1626 | <BR><HR><H4>Footnotes</H4> | |
1627 | <DL> | |
1628 | <DT><A NAME="foot394">... module.</A><A | |
1629 | href="built-in-funcs.html#tex2html2"><SUP>2.2</SUP></A></DT> | |
1630 | <DD>It is used relatively | |
1631 | rarely so does not warrant being made into a statement. | |
1632 | ||
1633 | </DD> | |
1634 | <DT><A NAME="foot1090">... used.</A><A | |
1635 | href="built-in-funcs.html#tex2html3"><SUP>2.3</SUP></A></DT> | |
1636 | <DD> | |
1637 | Specifying a buffer size currently has no effect on systems that | |
1638 | don't have <tt class="cfunction">setvbuf()</tt>. The interface to specify the | |
1639 | buffer size is not done using a method that calls | |
1640 | <tt class="cfunction">setvbuf()</tt>, because that may dump core when called | |
1641 | after any I/O has been performed, and there's no reliable way to | |
1642 | determine whether this is the case. | |
1643 | ||
1644 | </DD> | |
1645 | <DT><A NAME="foot996">... undefined.</A><A | |
1646 | href="built-in-funcs.html#tex2html4"><SUP>2.4</SUP></A></DT> | |
1647 | <DD> | |
1648 | In the current implementation, local variable bindings cannot | |
1649 | normally be affected this way, but variables retrieved from | |
1650 | other scopes (such as modules) can be. This may change. | |
1651 | ||
1652 | </DD> | |
1653 | </DL> | |
1654 | <DIV CLASS="navigation"> | |
1655 | <div class='online-navigation'> | |
1656 | <p></p><hr /> | |
1657 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
1658 | <tr> | |
1659 | <td class='online-navigation'><a rel="prev" title="2. Built-In Objects" | |
1660 | href="builtin.html"><img src='../icons/previous.png' | |
1661 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
1662 | <td class='online-navigation'><a rel="parent" title="2. Built-In Objects" | |
1663 | href="builtin.html"><img src='../icons/up.png' | |
1664 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
1665 | <td class='online-navigation'><a rel="next" title="2.2 Non-essential Built-in Functions" | |
1666 | href="non-essential-built-in-funcs.html"><img src='../icons/next.png' | |
1667 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
1668 | <td align="center" width="100%">Python Library Reference</td> | |
1669 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
1670 | href="contents.html"><img src='../icons/contents.png' | |
1671 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
1672 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
1673 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
1674 | <td class='online-navigation'><a rel="index" title="Index" | |
1675 | href="genindex.html"><img src='../icons/index.png' | |
1676 | border='0' height='32' alt='Index' width='32' /></A></td> | |
1677 | </tr></table> | |
1678 | <div class='online-navigation'> | |
1679 | <b class="navlabel">Previous:</b> | |
1680 | <a class="sectref" rel="prev" href="builtin.html">2. Built-In Objects</A> | |
1681 | <b class="navlabel">Up:</b> | |
1682 | <a class="sectref" rel="parent" href="builtin.html">2. Built-In Objects</A> | |
1683 | <b class="navlabel">Next:</b> | |
1684 | <a class="sectref" rel="next" href="non-essential-built-in-funcs.html">2.2 Non-essential Built-in Functions</A> | |
1685 | </div> | |
1686 | </div> | |
1687 | <hr /> | |
1688 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
1689 | </DIV> | |
1690 | <!--End of Navigation Panel--> | |
1691 | <ADDRESS> | |
1692 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
1693 | </ADDRESS> | |
1694 | </BODY> | |
1695 | </HTML> |