Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / built-in-funcs.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="non-essential-built-in-funcs.html" />
<link rel="prev" href="builtin.html" />
<link rel="parent" href="builtin.html" />
<link rel="next" href="non-essential-built-in-funcs.html" />
<meta name='aesop' content='information' />
<title>2.1 Built-in Functions </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="2. Built-In Objects"
href="builtin.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="2. Built-In Objects"
href="builtin.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="2.2 Non-essential Built-in Functions"
href="non-essential-built-in-funcs.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="builtin.html">2. Built-In Objects</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="builtin.html">2. Built-In Objects</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="non-essential-built-in-funcs.html">2.2 Non-essential Built-in Functions</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION004100000000000000000"></A><A NAME="built-in-funcs"></A>
<BR>
2.1 Built-in Functions
</H1>
<P>
The Python interpreter has a number of functions built into it that
are always available. They are listed here in alphabetical order.
<P>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-6' xml:id='l2h-6' class="function">__import__</tt></b>(</nobr></td>
<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>
<dd>
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
function that has a compatible interface, in order to change the
semantics of the <tt class="keyword">import</tt> statement. For examples of why
and how you would do this, see the standard library modules
<tt class="module">ihooks</tt><a id='l2h-80' xml:id='l2h-80'></a> and
<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
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
operations out of which you can build your own
<tt class="function">__import__()</tt> function.
<P>
For example, the statement "<tt class="samp">import spam</tt>" results in the
following call: <code>__import__('spam',</code> <code>globals(),</code>
<code>locals(), [])</code>; the statement "<tt class="samp">from spam.ham import eggs</tt>" results in "<tt class="samp">__import__('spam.ham', globals(), locals(),
['eggs'])</tt>". Note that even though <code>locals()</code> and
<code>['eggs']</code> are passed in as arguments, the
<tt class="function">__import__()</tt> function does not set the local variable
named <code>eggs</code>; this is done by subsequent code that is generated
for the import statement. (In fact, the standard implementation
does not use its <var>locals</var> argument at all, and uses its
<var>globals</var> only to determine the package context of the
<tt class="keyword">import</tt> statement.)
<P>
When the <var>name</var> variable is of the form <code>package.module</code>,
normally, the top-level package (the name up till the first dot) is
returned, <em>not</em> the module named by <var>name</var>. However, when
a non-empty <var>fromlist</var> argument is given, the module named by
<var>name</var> is returned. This is done for compatibility with the
bytecode generated for the different kinds of import statement; when
using "<tt class="samp">import spam.ham.eggs</tt>", the top-level package <tt class="module">spam</tt>
must be placed in the importing namespace, but when using "<tt class="samp">from
spam.ham import eggs</tt>", the <code>spam.ham</code> subpackage must be used
to find the <code>eggs</code> variable. As a workaround for this
behavior, use <tt class="function">getattr()</tt> to extract the desired
components. For example, you could define the following helper:
<P>
<div class="verbatim"><pre>
def my_import(name):
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
</pre></div>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-8' xml:id='l2h-8' class="function">abs</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the absolute value of a number. The argument may be a plain
or long integer or a floating point number. If the argument is a
complex number, its magnitude is returned.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-9' xml:id='l2h-9' class="function">basestring</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This abstract type is the superclass for <tt class="class">str</tt> and <tt class="class">unicode</tt>.
It cannot be called or instantiated, but it can be used to test whether
an object is an instance of <tt class="class">str</tt> or <tt class="class">unicode</tt>.
<code>isinstance(obj, basestring)</code> is equivalent to
<code>isinstance(obj, (str, unicode))</code>.
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-10' xml:id='l2h-10' class="function">bool</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>x</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Convert a value to a Boolean, using the standard truth testing
procedure. If <var>x</var> is false or omitted, this returns
<tt class="constant">False</tt>; otherwise it returns <tt class="constant">True</tt>.
<tt class="class">bool</tt> is also a class, which is a subclass of <tt class="class">int</tt>.
Class <tt class="class">bool</tt> cannot be subclassed further. Its only instances
are <tt class="constant">False</tt> and <tt class="constant">True</tt>.
<P>
<a id='l2h-11' xml:id='l2h-11'></a>
<span class="versionnote">New in version 2.2.1.</span>
<span class="versionnote">Changed in version 2.3:
If no argument is given, this function returns
<tt class="constant">False</tt>.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-12' xml:id='l2h-12' class="function">callable</tt></b>(</nobr></td>
<td><var>object</var>)</td></tr></table></dt>
<dd>
Return true if the <var>object</var> argument appears callable, false if
not. If this returns true, it is still possible that a call fails,
but if it is false, calling <var>object</var> will never succeed. Note
that classes are callable (calling a class returns a new instance);
class instances are callable if they have a <tt class="method">__call__()</tt>
method.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-13' xml:id='l2h-13' class="function">chr</tt></b>(</nobr></td>
<td><var>i</var>)</td></tr></table></dt>
<dd>
Return a string of one character whose ASCII code is the integer
<var>i</var>. For example, <code>chr(97)</code> returns the string <code>'a'</code>.
This is the inverse of <tt class="function">ord()</tt>. The argument must be in
the range [0..255], inclusive; <tt class="exception">ValueError</tt> will be raised
if <var>i</var> is outside that range.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-14' xml:id='l2h-14' class="function">classmethod</tt></b>(</nobr></td>
<td><var>function</var>)</td></tr></table></dt>
<dd>
Return a class method for <var>function</var>.
<P>
A class method receives the class as implicit first argument,
just like an instance method receives the instance.
To declare a class method, use this idiom:
<P>
<div class="verbatim"><pre>
class C:
@classmethod
def f(cls, arg1, arg2, ...): ...
</pre></div>
<P>
The <code>@classmethod</code> form is a function decorator - see the description
of function definitions in chapter 7 of the
<em class="citetitle"><a
href="../ref/ref.html"
title="Python Reference Manual"
>Python Reference Manual</a></em> for details.
<P>
It can be called either on the class (such as <code>C.f()</code>) or on an
instance (such as <code>C().f()</code>). The instance is ignored except for
its class.
If a class method is called for a derived class, the derived class
object is passed as the implied first argument.
<P>
Class methods are different than C++ or Java static methods.
If you want those, see <tt class="function">staticmethod()</tt> in this section.
<span class="versionnote">New in version 2.2.</span>
<span class="versionnote">Changed in version 2.4:
Function decorator syntax added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-15' xml:id='l2h-15' class="function">cmp</tt></b>(</nobr></td>
<td><var>x, y</var>)</td></tr></table></dt>
<dd>
Compare the two objects <var>x</var> and <var>y</var> and return an integer
according to the outcome. The return value is negative if <code><var>x</var>
&lt; <var>y</var></code>, zero if <code><var>x</var> == <var>y</var></code> and strictly positive if
<code><var>x</var> &gt; <var>y</var></code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-16' xml:id='l2h-16' class="function">compile</tt></b>(</nobr></td>
<td><var>string, filename, kind</var><big>[</big><var>,
flags</var><big>[</big><var>, dont_inherit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Compile the <var>string</var> into a code object. Code objects can be
executed by an <tt class="keyword">exec</tt> statement or evaluated by a call to
<tt class="function">eval()</tt>. The <var>filename</var> argument should
give the file from which the code was read; pass some recognizable value
if it wasn't read from a file (<code>'&lt;string&gt;'</code> is commonly used).
The <var>kind</var> argument specifies what kind of code must be
compiled; it can be <code>'exec'</code> if <var>string</var> consists of a
sequence of statements, <code>'eval'</code> if it consists of a single
expression, or <code>'single'</code> if it consists of a single
interactive statement (in the latter case, expression statements
that evaluate to something else than <code>None</code> will be printed).
<P>
When compiling multi-line statements, two caveats apply: line
endings must be represented by a single newline character
(<code>'&#92;n'</code>), and the input must be terminated by at least one
newline character. If line endings are represented by
<code>'&#92;r&#92;n'</code>, use the string <tt class="method">replace()</tt> method to
change them into <code>'&#92;n'</code>.
<P>
The optional arguments <var>flags</var> and <var>dont_inherit</var>
(which are new in Python 2.2) control which future statements (see
<a class="rfc" id='rfcref-85712' xml:id='rfcref-85712'
href="http://www.python.org/peps/pep-0236.html">PEP 236</a>) affect the compilation of <var>string</var>. If neither is
present (or both are zero) the code is compiled with those future
statements that are in effect in the code that is calling compile.
If the <var>flags</var> argument is given and <var>dont_inherit</var> is not
(or is zero) then the future statements specified by the <var>flags</var>
argument are used in addition to those that would be used anyway.
If <var>dont_inherit</var> is a non-zero integer then the <var>flags</var>
argument is it - the future statements in effect around the call to
compile are ignored.
<P>
Future statements are specified by bits which can be bitwise or-ed
together to specify multiple statements. The bitfield required to
specify a given feature can be found as the <tt class="member">compiler_flag</tt>
attribute on the <tt class="class">_Feature</tt> instance in the
<tt class="module">__future__</tt> module.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-17' xml:id='l2h-17' class="function">complex</tt></b>(</nobr></td>
<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>
<dd>
Create a complex number with the value <var>real</var> + <var>imag</var>*j or
convert a string or number to a complex number. If the first
parameter is a string, it will be interpreted as a complex number
and the function must be called without a second parameter. The
second parameter can never be a string.
Each argument may be any numeric type (including complex).
If <var>imag</var> is omitted, it defaults to zero and the function
serves as a numeric conversion function like <tt class="function">int()</tt>,
<tt class="function">long()</tt> and <tt class="function">float()</tt>. If both arguments
are omitted, returns <code>0j</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-18' xml:id='l2h-18' class="function">delattr</tt></b>(</nobr></td>
<td><var>object, name</var>)</td></tr></table></dt>
<dd>
This is a relative of <tt class="function">setattr()</tt>. The arguments are an
object and a string. The string must be the name
of one of the object's attributes. The function deletes
the named attribute, provided the object allows it. For example,
<code>delattr(<var>x</var>, '<var>foobar</var>')</code> is equivalent to
<code>del <var>x</var>.<var>foobar</var></code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-19' xml:id='l2h-19' class="function">dict</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>mapping-or-sequence</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a new dictionary initialized from an optional positional
argument or from a set of keyword arguments.
If no arguments are given, return a new empty dictionary.
If the positional argument is a mapping object, return a dictionary
mapping the same keys to the same values as does the mapping object.
Otherwise the positional argument must be a sequence, a container that
supports iteration, or an iterator object. The elements of the argument
must each also be of one of those kinds, and each must in turn contain
exactly two objects. The first is used as a key in the new dictionary,
and the second as the key's value. If a given key is seen more than
once, the last value associated with it is retained in the new
dictionary.
<P>
If keyword arguments are given, the keywords themselves with their
associated values are added as items to the dictionary. If a key
is specified both in the positional argument and as a keyword argument,
the value associated with the keyword is retained in the dictionary.
For example, these all return a dictionary equal to
<code>{"one": 2, "two": 3}</code>:
<P>
<UL>
<LI><code>dict({'one': 2, 'two': 3})</code>
</LI>
<LI><code>dict({'one': 2, 'two': 3}.items())</code>
</LI>
<LI><code>dict({'one': 2, 'two': 3}.iteritems())</code>
</LI>
<LI><code>dict(zip(('one', 'two'), (2, 3)))</code>
</LI>
<LI><code>dict([['two', 3], ['one', 2]])</code>
</LI>
<LI><code>dict(one=2, two=3)</code>
</LI>
<LI><code>dict([(['one', 'two'][i-2], i) for i in (2, 3)])</code>
</LI>
</UL>
<P>
<span class="versionnote">New in version 2.2.</span>
<span class="versionnote">Changed in version 2.3:
Support for building a dictionary from keyword
arguments added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-20' xml:id='l2h-20' class="function">dir</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Without arguments, return the list of names in the current local
symbol table. With an argument, attempts to return a list of valid
attributes for that object. This information is gleaned from the
object's <tt class="member">__dict__</tt> attribute, if defined, and from the class
or type object. The list is not necessarily complete.
If the object is a module object, the list contains the names of the
module's attributes.
If the object is a type or class object,
the list contains the names of its attributes,
and recursively of the attributes of its bases.
Otherwise, the list contains the object's attributes' names,
the names of its class's attributes,
and recursively of the attributes of its class's base classes.
The resulting list is sorted alphabetically.
For example:
<P>
<div class="verbatim"><pre>
&gt;&gt;&gt; import struct
&gt;&gt;&gt; dir()
['__builtins__', '__doc__', '__name__', 'struct']
&gt;&gt;&gt; dir(struct)
['__doc__', '__name__', 'calcsize', 'error', 'pack', 'unpack']
</pre></div>
<P>
<span class="note"><b class="label">Note:</b>
Because <tt class="function">dir()</tt> is supplied primarily as a convenience
for use at an interactive prompt,
it tries to supply an interesting set of names more than it tries to
supply a rigorously or consistently defined set of names,
and its detailed behavior may change across releases.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-21' xml:id='l2h-21' class="function">divmod</tt></b>(</nobr></td>
<td><var>a, b</var>)</td></tr></table></dt>
<dd>
Take two (non complex) numbers as arguments and return a pair of numbers
consisting of their quotient and remainder when using long division. With
mixed operand types, the rules for binary arithmetic operators apply. For
plain and long integers, the result is the same as
<code>(<var>a</var> / <var>b</var>, <var>a</var> % <var>b</var>)</code>.
For floating point numbers the result is <code>(<var>q</var>, <var>a</var> %
<var>b</var>)</code>, where <var>q</var> is usually <code>math.floor(<var>a</var> /
<var>b</var>)</code> but may be 1 less than that. In any case <code><var>q</var> *
<var>b</var> + <var>a</var> % <var>b</var></code> is very close to <var>a</var>, if
<code><var>a</var> % <var>b</var></code> is non-zero it has the same sign as
<var>b</var>, and <code>0 &lt;= abs(<var>a</var> % <var>b</var>) &lt; abs(<var>b</var>)</code>.
<P>
<span class="versionnote">Changed in version 2.3:
Using <tt class="function">divmod()</tt> with complex numbers is
deprecated.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-22' xml:id='l2h-22' class="function">enumerate</tt></b>(</nobr></td>
<td><var>iterable</var>)</td></tr></table></dt>
<dd>
Return an enumerate object. <var>iterable</var> must be a sequence, an
iterator, or some other object which supports iteration. The
<tt class="method">next()</tt> method of the iterator returned by
<tt class="function">enumerate()</tt> returns a tuple containing a count (from
zero) and the corresponding value obtained from iterating over
<var>iterable</var>. <tt class="function">enumerate()</tt> is useful for obtaining an
indexed series: <code>(0, seq[0])</code>, <code>(1, seq[1])</code>, <code>(2,
seq[2])</code>, ....
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-23' xml:id='l2h-23' class="function">eval</tt></b>(</nobr></td>
<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>
<dd>
The arguments are a string and optional globals and locals. If provided,
<var>globals</var> must be a dictionary. If provided, <var>locals</var> can be
any mapping object.
<span class="versionnote">Changed in version 2.4:
formerly <var>locals</var> was required
to be a dictionary.</span>
<P>
The <var>expression</var> argument is parsed and evaluated as a Python
expression (technically speaking, a condition list) using the
<var>globals</var> and <var>locals</var> dictionaries as global and local name
space. If the <var>globals</var> dictionary is present and lacks
'__builtins__', the current globals are copied into <var>globals</var> before
<var>expression</var> is parsed. This means that <var>expression</var>
normally has full access to the standard
<tt class="module"><a href="module-builtin.html">__builtin__</a></tt> module and restricted environments
are propagated. If the <var>locals</var> dictionary is omitted it defaults to
the <var>globals</var> dictionary. If both dictionaries are omitted, the
expression is executed in the environment where <tt class="keyword">eval</tt> is
called. The return value is the result of the evaluated expression.
Syntax errors are reported as exceptions. Example:
<P>
<div class="verbatim"><pre>
&gt;&gt;&gt; x = 1
&gt;&gt;&gt; print eval('x+1')
2
</pre></div>
<P>
This function can also be used to execute arbitrary code objects
(such as those created by <tt class="function">compile()</tt>). In this case pass
a code object instead of a string. The code object must have been
compiled passing <code>'eval'</code> as the <var>kind</var> argument.
<P>
Hints: dynamic execution of statements is supported by the
<tt class="keyword">exec</tt> statement. Execution of statements from a file is
supported by the <tt class="function">execfile()</tt> function. The
<tt class="function">globals()</tt> and <tt class="function">locals()</tt> functions returns the
current global and local dictionary, respectively, which may be
useful to pass around for use by <tt class="function">eval()</tt> or
<tt class="function">execfile()</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-24' xml:id='l2h-24' class="function">execfile</tt></b>(</nobr></td>
<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>
<dd>
This function is similar to the
<tt class="keyword">exec</tt> statement, but parses a file instead of a string. It
is different from the <tt class="keyword">import</tt> statement in that it does not
use the module administration -- it reads the file unconditionally
and does not create a new module.<A NAME="tex2html2"
HREF="#foot394"><SUP>2.2</SUP></A>
<P>
The arguments are a file name and two optional dictionaries. The file is
parsed and evaluated as a sequence of Python statements (similarly to a
module) using the <var>globals</var> and <var>locals</var> dictionaries as global and
local namespace. If provided, <var>locals</var> can be any mapping object.
<span class="versionnote">Changed in version 2.4:
formerly <var>locals</var> was required to be a dictionary.</span>
If the <var>locals</var> dictionary is omitted it defaults to the <var>globals</var>
dictionary. If both dictionaries are omitted, the expression is executed in
the environment where <tt class="function">execfile()</tt> is called. The return value is
<code>None</code>.
<P>
<span class="warning"><b class="label">Warning:</b>
The default <var>locals</var> act as described for function
<tt class="function">locals()</tt> below: modifications to the default <var>locals</var>
dictionary should not be attempted. Pass an explicit <var>locals</var>
dictionary if you need to see effects of the code on <var>locals</var> after
function <tt class="function">execfile()</tt> returns. <tt class="function">execfile()</tt> cannot
be used reliably to modify a function's locals.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-25' xml:id='l2h-25' class="function">file</tt></b>(</nobr></td>
<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>
<dd>
Return a new file object (described in
section&nbsp;<A href="bltin-file-objects.html#bltin-file-objects">2.3.9</A>, ``<a class="ulink" href="bltin-file-objects.html"
>File
Objects</a>'').
The first two arguments are the same as for <code>stdio</code>'s
<tt class="cfunction">fopen()</tt>: <var>filename</var> is the file name to be opened,
<var>mode</var> indicates how the file is to be opened: <code>'r'</code> for
reading, <code>'w'</code> for writing (truncating an existing file), and
<code>'a'</code> opens it for appending (which on <em>some</em> <span class="Unix">Unix</span>
systems means that <em>all</em> writes append to the end of the file,
regardless of the current seek position).
<P>
Modes <code>'r+'</code>, <code>'w+'</code> and <code>'a+'</code> open the file for
updating (note that <code>'w+'</code> truncates the file). Append
<code>'b'</code> to the mode to open the file in binary mode, on systems
that differentiate between binary and text files (else it is
ignored). If the file cannot be opened, <tt class="exception">IOError</tt> is
raised.
<P>
In addition to the standard <tt class="cfunction">fopen()</tt> values <var>mode</var>
may be <code>'U'</code> or <code>'rU'</code>. If Python is built with universal
newline support (the default) the file is opened as a text file, but
lines may be terminated by any of <code>'&#92;n'</code>, the Unix end-of-line
convention,
<code>'&#92;r'</code>, the Macintosh convention or <code>'&#92;r&#92;n'</code>, the Windows
convention. All of these external representations are seen as
<code>'&#92;n'</code>
by the Python program. If Python is built without universal newline support
<var>mode</var> <code>'U'</code> is the same as normal text mode. Note that
file objects so opened also have an attribute called
<tt class="member">newlines</tt> which has a value of <code>None</code> (if no newlines
have yet been seen), <code>'&#92;n'</code>, <code>'&#92;r'</code>, <code>'&#92;r&#92;n'</code>,
or a tuple containing all the newline types seen.
<P>
If <var>mode</var> is omitted, it defaults to <code>'r'</code>. When opening a
binary file, you should append <code>'b'</code> to the <var>mode</var> value
for improved portability. (It's useful even on systems which don't
treat binary and text files differently, where it serves as
documentation.)
<a id='l2h-83' xml:id='l2h-83'></a>
The optional <var>bufsize</var> argument specifies the
file's desired buffer size: 0 means unbuffered, 1 means line
buffered, any other positive value means use a buffer of
(approximately) that size. A negative <var>bufsize</var> means to use
the system default, which is usually line buffered for tty
devices and fully buffered for other files. If omitted, the system
default is used.<A NAME="tex2html3"
HREF="#foot1090"><SUP>2.3</SUP></A>
<P>
The <tt class="function">file()</tt> constructor is new in Python 2.2 and is an
alias for <tt class="function">open()</tt>. Both spellings are equivalent. The
intent is for <tt class="function">open()</tt> to continue to be preferred for use
as a factory function which returns a new <tt class="class">file</tt> object. The
spelling, <tt class="class">file</tt> is more suited to type testing (for example,
writing "<tt class="samp">isinstance(f, file)</tt>").
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-26' xml:id='l2h-26' class="function">filter</tt></b>(</nobr></td>
<td><var>function, list</var>)</td></tr></table></dt>
<dd>
Construct a list from those elements of <var>list</var> for which
<var>function</var> returns true. <var>list</var> may be either a sequence, a
container which supports iteration, or an iterator, If <var>list</var>
is a string or a tuple, the result also has that type; otherwise it
is always a list. If <var>function</var> is <code>None</code>, the identity
function is assumed, that is, all elements of <var>list</var> that are false
(zero or empty) are removed.
<P>
Note that <code>filter(function, <var>list</var>)</code> is equivalent to
<code>[item for item in <var>list</var> if function(item)]</code> if function is
not <code>None</code> and <code>[item for item in <var>list</var> if item]</code> if
function is <code>None</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-27' xml:id='l2h-27' class="function">float</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>x</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Convert a string or a number to floating point. If the argument is a
string, it must contain a possibly signed decimal or floating point
number, possibly embedded in whitespace. Otherwise, the argument may be a plain
or long integer or a floating point number, and a floating point
number with the same value (within Python's floating point
precision) is returned. If no argument is given, returns <code>0.0</code>.
<P>
<span class="note"><b class="label">Note:</b>
When passing in a string, values for NaN<a id='l2h-28' xml:id='l2h-28'></a>
and Infinity<a id='l2h-29' xml:id='l2h-29'></a> may be returned, depending on the
underlying C library. The specific set of strings accepted which
cause these values to be returned depends entirely on the C library
and is known to vary.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-30' xml:id='l2h-30' class="function">frozenset</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>iterable</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a frozenset object whose elements are taken from <var>iterable</var>.
Frozensets are sets that have no update methods but can be hashed and
used as members of other sets or as dictionary keys. The elements of
a frozenset must be immutable themselves. To represent sets of sets,
the inner sets should also be <tt class="class">frozenset</tt> objects. If
<var>iterable</var> is not specified, returns a new empty set,
<code>frozenset([])</code>.
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-31' xml:id='l2h-31' class="function">getattr</tt></b>(</nobr></td>
<td><var>object, name</var><big>[</big><var>, default</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the value of the named attributed of <var>object</var>. <var>name</var>
must be a string. If the string is the name of one of the object's
attributes, the result is the value of that attribute. For example,
<code>getattr(x, 'foobar')</code> is equivalent to <code>x.foobar</code>. If the
named attribute does not exist, <var>default</var> is returned if provided,
otherwise <tt class="exception">AttributeError</tt> is raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-32' xml:id='l2h-32' class="function">globals</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a dictionary representing the current global symbol table.
This is always the dictionary of the current module (inside a
function or method, this is the module where it is defined, not the
module from which it is called).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-33' xml:id='l2h-33' class="function">hasattr</tt></b>(</nobr></td>
<td><var>object, name</var>)</td></tr></table></dt>
<dd>
The arguments are an object and a string. The result is <code>True</code> if the
string is the name of one of the object's attributes, <code>False</code> if not.
(This is implemented by calling <code>getattr(<var>object</var>,
<var>name</var>)</code> and seeing whether it raises an exception or not.)
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-34' xml:id='l2h-34' class="function">hash</tt></b>(</nobr></td>
<td><var>object</var>)</td></tr></table></dt>
<dd>
Return the hash value of the object (if it has one). Hash values
are integers. They are used to quickly compare dictionary
keys during a dictionary lookup. Numeric values that compare equal
have the same hash value (even if they are of different types, as is
the case for 1 and 1.0).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-35' xml:id='l2h-35' class="function">help</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Invoke the built-in help system. (This function is intended for
interactive use.) If no argument is given, the interactive help
system starts on the interpreter console. If the argument is a
string, then the string is looked up as the name of a module,
function, class, method, keyword, or documentation topic, and a
help page is printed on the console. If the argument is any other
kind of object, a help page on the object is generated.
<span class="versionnote">New in version 2.2.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-36' xml:id='l2h-36' class="function">hex</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Convert an integer number (of any size) to a hexadecimal string.
The result is a valid Python expression.
<span class="versionnote">Changed in version 2.4:
Formerly only returned an unsigned literal..</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-37' xml:id='l2h-37' class="function">id</tt></b>(</nobr></td>
<td><var>object</var>)</td></tr></table></dt>
<dd>
Return the ``identity'' of an object. This is an integer (or long
integer) which is guaranteed to be unique and constant for this
object during its lifetime. Two objects with non-overlapping lifetimes
may have the same <tt class="function">id()</tt> value. (Implementation
note: this is the address of the object.)
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-38' xml:id='l2h-38' class="function">input</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>prompt</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Equivalent to <code>eval(raw_input(<var>prompt</var>))</code>.
<span class="warning"><b class="label">Warning:</b>
This function is not safe from user errors! It
expects a valid Python expression as input; if the input is not
syntactically valid, a <tt class="exception">SyntaxError</tt> will be raised.
Other exceptions may be raised if there is an error during
evaluation. (On the other hand, sometimes this is exactly what you
need when writing a quick script for expert use.)</span>
<P>
If the <tt class="module"><a href="module-readline.html">readline</a></tt> module was loaded, then
<tt class="function">input()</tt> will use it to provide elaborate line editing and
history features.
<P>
Consider using the <tt class="function">raw_input()</tt> function for general input
from users.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-39' xml:id='l2h-39' class="function">int</tt></b>(</nobr></td>
<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>
<dd>
Convert a string or number to a plain integer. If the argument is a
string, it must contain a possibly signed decimal number
representable as a Python integer, possibly embedded in whitespace.
The <var>radix</var> parameter gives the base for the
conversion and may be any integer in the range [2, 36], or zero. If
<var>radix</var> is zero, the proper radix is guessed based on the
contents of string; the interpretation is the same as for integer
literals. If <var>radix</var> is specified and <var>x</var> is not a string,
<tt class="exception">TypeError</tt> is raised.
Otherwise, the argument may be a plain or
long integer or a floating point number. Conversion of floating
point numbers to integers truncates (towards zero).
If the argument is outside the integer range a long object will
be returned instead. If no arguments are given, returns <code>0</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-40' xml:id='l2h-40' class="function">isinstance</tt></b>(</nobr></td>
<td><var>object, classinfo</var>)</td></tr></table></dt>
<dd>
Return true if the <var>object</var> argument is an instance of the
<var>classinfo</var> argument, or of a (direct or indirect) subclass
thereof. Also return true if <var>classinfo</var> is a type object and
<var>object</var> is an object of that type. If <var>object</var> is not a
class instance or an object of the given type, the function always
returns false. If <var>classinfo</var> is neither a class object nor a
type object, it may be a tuple of class or type objects, or may
recursively contain other such tuples (other sequence types are not
accepted). If <var>classinfo</var> is not a class, type, or tuple of
classes, types, and such tuples, a <tt class="exception">TypeError</tt> exception
is raised.
<span class="versionnote">Changed in version 2.2:
Support for a tuple of type information was added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-41' xml:id='l2h-41' class="function">issubclass</tt></b>(</nobr></td>
<td><var>class, classinfo</var>)</td></tr></table></dt>
<dd>
Return true if <var>class</var> is a subclass (direct or indirect) of
<var>classinfo</var>. A class is considered a subclass of itself.
<var>classinfo</var> may be a tuple of class objects, in which case every
entry in <var>classinfo</var> will be checked. In any other case, a
<tt class="exception">TypeError</tt> exception is raised.
<span class="versionnote">Changed in version 2.3:
Support for a tuple of type information was added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-42' xml:id='l2h-42' class="function">iter</tt></b>(</nobr></td>
<td><var>o</var><big>[</big><var>, sentinel</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return an iterator object. The first argument is interpreted very
differently depending on the presence of the second argument.
Without a second argument, <var>o</var> must be a collection object which
supports the iteration protocol (the <tt class="method">__iter__()</tt> method), or
it must support the sequence protocol (the <tt class="method">__getitem__()</tt>
method with integer arguments starting at <code>0</code>). If it does not
support either of those protocols, <tt class="exception">TypeError</tt> is raised.
If the second argument, <var>sentinel</var>, is given, then <var>o</var> must
be a callable object. The iterator created in this case will call
<var>o</var> with no arguments for each call to its <tt class="method">next()</tt>
method; if the value returned is equal to <var>sentinel</var>,
<tt class="exception">StopIteration</tt> will be raised, otherwise the value will
be returned.
<span class="versionnote">New in version 2.2.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-43' xml:id='l2h-43' class="function">len</tt></b>(</nobr></td>
<td><var>s</var>)</td></tr></table></dt>
<dd>
Return the length (the number of items) of an object. The argument
may be a sequence (string, tuple or list) or a mapping (dictionary).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-44' xml:id='l2h-44' class="function">list</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>sequence</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a list whose items are the same and in the same order as
<var>sequence</var>'s items. <var>sequence</var> may be either a sequence, a
container that supports iteration, or an iterator object. If
<var>sequence</var> is already a list, a copy is made and returned,
similar to <code><var>sequence</var>[:]</code>. For instance,
<code>list('abc')</code> returns <code>['a', 'b', 'c']</code> and <code>list(
(1, 2, 3) )</code> returns <code>[1, 2, 3]</code>. If no argument is given,
returns a new empty list, <code>[]</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-45' xml:id='l2h-45' class="function">locals</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Update and return a dictionary representing the current local symbol table.
<span class="warning"><b class="label">Warning:</b>
The contents of this dictionary should not be modified;
changes may not affect the values of local variables used by the
interpreter.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-46' xml:id='l2h-46' class="function">long</tt></b>(</nobr></td>
<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>
<dd>
Convert a string or number to a long integer. If the argument is a
string, it must contain a possibly signed number of
arbitrary size, possibly embedded in whitespace. The
<var>radix</var> argument is interpreted in the same way as for
<tt class="function">int()</tt>, and may only be given when <var>x</var> is a string.
Otherwise, the argument may be a plain or
long integer or a floating point number, and a long integer with
the same value is returned. Conversion of floating
point numbers to integers truncates (towards zero). If no arguments
are given, returns <code>0L</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-47' xml:id='l2h-47' class="function">map</tt></b>(</nobr></td>
<td><var>function, list, ...</var>)</td></tr></table></dt>
<dd>
Apply <var>function</var> to every item of <var>list</var> and return a list
of the results. If additional <var>list</var> arguments are passed,
<var>function</var> must take that many arguments and is applied to the
items of all lists in parallel; if a list is shorter than another it
is assumed to be extended with <code>None</code> items. If <var>function</var>
is <code>None</code>, the identity function is assumed; if there are
multiple list arguments, <tt class="function">map()</tt> returns a list consisting
of tuples containing the corresponding items from all lists (a kind
of transpose operation). The <var>list</var> arguments may be any kind
of sequence; the result is always a list.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-48' xml:id='l2h-48' class="function">max</tt></b>(</nobr></td>
<td><var>s</var><big>[</big><var>, args...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
With a single argument <var>s</var>, return the largest item of a
non-empty sequence (such as a string, tuple or list). With more
than one argument, return the largest of the arguments.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-49' xml:id='l2h-49' class="function">min</tt></b>(</nobr></td>
<td><var>s</var><big>[</big><var>, args...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
With a single argument <var>s</var>, return the smallest item of a
non-empty sequence (such as a string, tuple or list). With more
than one argument, return the smallest of the arguments.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-50' xml:id='l2h-50' class="function">object</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a new featureless object. <tt class="function">object()</tt> is a base
for all new style classes. It has the methods that are common
to all instances of new style classes.
<span class="versionnote">New in version 2.2.</span>
<P>
<span class="versionnote">Changed in version 2.3:
This function does not accept any arguments.
Formerly, it accepted arguments but ignored them.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-51' xml:id='l2h-51' class="function">oct</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Convert an integer number (of any size) to an octal string. The
result is a valid Python expression.
<span class="versionnote">Changed in version 2.4:
Formerly only returned an unsigned literal..</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-52' xml:id='l2h-52' class="function">open</tt></b>(</nobr></td>
<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>
<dd>
An alias for the <tt class="function">file()</tt> function above.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-53' xml:id='l2h-53' class="function">ord</tt></b>(</nobr></td>
<td><var>c</var>)</td></tr></table></dt>
<dd>
Given a string of length one, return an integer representing the
Unicode code point of the character when the argument is a unicode object,
or the value of the byte when the argument is an 8-bit string.
For example, <code>ord('a')</code> returns the integer <code>97</code>,
<code>ord(u'&#92;u2020')</code> returns <code>8224</code>. This is the inverse of
<tt class="function">chr()</tt> for 8-bit strings and of <tt class="function">unichr()</tt> for unicode
objects. If a unicode argument is given and Python was built with
UCS2 Unicode, then the character's code point must be in the range
[0..65535] inclusive; otherwise the string length is two, and a
<tt class="exception">TypeError</tt> will be raised.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-54' xml:id='l2h-54' class="function">pow</tt></b>(</nobr></td>
<td><var>x, y</var><big>[</big><var>, z</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return <var>x</var> to the power <var>y</var>; if <var>z</var> is present, return
<var>x</var> to the power <var>y</var>, modulo <var>z</var> (computed more
efficiently than <code>pow(<var>x</var>, <var>y</var>) % <var>z</var></code>). The
arguments must have numeric types. With mixed operand types, the
coercion rules for binary arithmetic operators apply. For int and
long int operands, the result has the same type as the operands
(after coercion) unless the second argument is negative; in that
case, all arguments are converted to float and a float result is
delivered. For example, <code>10**2</code> returns <code>100</code>, but
<code>10**-2</code> returns <code>0.01</code>. (This last feature was added in
Python 2.2. In Python 2.1 and before, if both arguments were of integer
types and the second argument was negative, an exception was raised.)
If the second argument is negative, the third argument must be omitted.
If <var>z</var> is present, <var>x</var> and <var>y</var> must be of integer types,
and <var>y</var> must be non-negative. (This restriction was added in
Python 2.2. In Python 2.1 and before, floating 3-argument <code>pow()</code>
returned platform-dependent results depending on floating-point
rounding accidents.)
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-55' xml:id='l2h-55' class="function">property</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>fget</var><big>[</big><var>, fset</var><big>[</big><var>,
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>
<dd>
Return a property attribute for new-style classes (classes that
derive from <tt class="class">object</tt>).
<P>
<var>fget</var> is a function for getting an attribute value, likewise
<var>fset</var> is a function for setting, and <var>fdel</var> a function
for del'ing, an attribute. Typical use is to define a managed attribute x:
<P>
<div class="verbatim"><pre>
class C(object):
def __init__(self): self.__x = None
def getx(self): return self.__x
def setx(self, value): self.__x = value
def delx(self): del self.__x
x = property(getx, setx, delx, "I'm the 'x' property.")
</pre></div>
<P>
<span class="versionnote">New in version 2.2.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-56' xml:id='l2h-56' class="function">range</tt></b>(</nobr></td>
<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>
<dd>
This is a versatile function to create lists containing arithmetic
progressions. It is most often used in <tt class="keyword">for</tt> loops. The
arguments must be plain integers. If the <var>step</var> argument is
omitted, it defaults to <code>1</code>. If the <var>start</var> argument is
omitted, it defaults to <code>0</code>. The full form returns a list of
plain integers <code>[<var>start</var>, <var>start</var> + <var>step</var>,
<var>start</var> + 2 * <var>step</var>, ...]</code>. If <var>step</var> is positive,
the last element is the largest <code><var>start</var> + <var>i</var> *
<var>step</var></code> less than <var>stop</var>; if <var>step</var> is negative, the last
element is the smallest <code><var>start</var> + <var>i</var> * <var>step</var></code>
greater than <var>stop</var>. <var>step</var> must not be zero (or else
<tt class="exception">ValueError</tt> is raised). Example:
<P>
<div class="verbatim"><pre>
&gt;&gt;&gt; range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
&gt;&gt;&gt; range(1, 11)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
&gt;&gt;&gt; range(0, 30, 5)
[0, 5, 10, 15, 20, 25]
&gt;&gt;&gt; range(0, 10, 3)
[0, 3, 6, 9]
&gt;&gt;&gt; range(0, -10, -1)
[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
&gt;&gt;&gt; range(0)
[]
&gt;&gt;&gt; range(1, 0)
[]
</pre></div>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-57' xml:id='l2h-57' class="function">raw_input</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>prompt</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
If the <var>prompt</var> argument is present, it is written to standard output
without a trailing newline. The function then reads a line from input,
converts it to a string (stripping a trailing newline), and returns that.
When EOF is read, <tt class="exception">EOFError</tt> is raised. Example:
<P>
<div class="verbatim"><pre>
&gt;&gt;&gt; s = raw_input('--&gt; ')
--&gt; Monty Python's Flying Circus
&gt;&gt;&gt; s
"Monty Python's Flying Circus"
</pre></div>
<P>
If the <tt class="module"><a href="module-readline.html">readline</a></tt> module was loaded, then
<tt class="function">raw_input()</tt> will use it to provide elaborate
line editing and history features.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-58' xml:id='l2h-58' class="function">reduce</tt></b>(</nobr></td>
<td><var>function, sequence</var><big>[</big><var>, initializer</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Apply <var>function</var> of two arguments cumulatively to the items of
<var>sequence</var>, from left to right, so as to reduce the sequence to
a single value. For example, <code>reduce(lambda x, y: x+y, [1, 2,
3, 4, 5])</code> calculates <code>((((1+2)+3)+4)+5)</code>. The left argument,
<var>x</var>, is the accumulated value and the right argument, <var>y</var>,
is the update value from the <var>sequence</var>. If the optional
<var>initializer</var> is present, it is placed before the items of the
sequence in the calculation, and serves as a default when the
sequence is empty. If <var>initializer</var> is not given and
<var>sequence</var> contains only one item, the first item is returned.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-59' xml:id='l2h-59' class="function">reload</tt></b>(</nobr></td>
<td><var>module</var>)</td></tr></table></dt>
<dd>
Reload a previously imported <var>module</var>. The
argument must be a module object, so it must have been successfully
imported before. This is useful if you have edited the module
source file using an external editor and want to try out the new
version without leaving the Python interpreter. The return value is
the module object (the same as the <var>module</var> argument).
<P>
When <code>reload(module)</code> is executed:
<P>
<UL>
<LI>Python modules' code is recompiled and the module-level code
reexecuted, defining a new set of objects which are bound to names in
the module's dictionary. The <code>init</code> function of extension
modules is not called a second time.
<P>
</LI>
<LI>As with all other objects in Python the old objects are only
reclaimed after their reference counts drop to zero.
<P>
</LI>
<LI>The names in the module namespace are updated to point to
any new or changed objects.
<P>
</LI>
<LI>Other references to the old objects (such as names external
to the module) are not rebound to refer to the new objects and
must be updated in each namespace where they occur if that is
desired.
<P>
</LI>
</UL>
<P>
There are a number of other caveats:
<P>
If a module is syntactically correct but its initialization fails,
the first <tt class="keyword">import</tt> statement for it does not bind its name
locally, but does store a (partially initialized) module object in
<code>sys.modules</code>. To reload the module you must first
<tt class="keyword">import</tt> it again (this will bind the name to the partially
initialized module object) before you can <tt class="function">reload()</tt> it.
<P>
When a module is reloaded, its dictionary (containing the module's
global variables) is retained. Redefinitions of names will override
the old definitions, so this is generally not a problem. If the new
version of a module does not define a name that was defined by the
old version, the old definition remains. This feature can be used
to the module's advantage if it maintains a global table or cache of
objects -- with a <tt class="keyword">try</tt> statement it can test for the
table's presence and skip its initialization if desired:
<P>
<div class="verbatim"><pre>
try:
cache
except NameError:
cache = {}
</pre></div>
<P>
It is legal though generally not very useful to reload built-in or
dynamically loaded modules, except for <tt class="module"><a href="module-sys.html">sys</a></tt>,
<tt class="module"><a href="module-main.html">__main__</a></tt> and <tt class="module"><a href="module-builtin.html">__builtin__</a></tt>. In
many cases, however, extension modules are not designed to be
initialized more than once, and may fail in arbitrary ways when
reloaded.
<P>
If a module imports objects from another module using <tt class="keyword">from</tt>
... <tt class="keyword">import</tt> ..., calling <tt class="function">reload()</tt> for
the other module does not redefine the objects imported from it --
one way around this is to re-execute the <tt class="keyword">from</tt> statement,
another is to use <tt class="keyword">import</tt> and qualified names
(<var>module</var>.<var>name</var>) instead.
<P>
If a module instantiates instances of a class, reloading the module
that defines the class does not affect the method definitions of the
instances -- they continue to use the old class definition. The
same is true for derived classes.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-60' xml:id='l2h-60' class="function">repr</tt></b>(</nobr></td>
<td><var>object</var>)</td></tr></table></dt>
<dd>
Return a string containing a printable representation of an object.
This is the same value yielded by conversions (reverse quotes).
It is sometimes useful to be able to access this operation as an
ordinary function. For many types, this function makes an attempt
to return a string that would yield an object with the same value
when passed to <tt class="function">eval()</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-61' xml:id='l2h-61' class="function">reversed</tt></b>(</nobr></td>
<td><var>seq</var>)</td></tr></table></dt>
<dd>
Return a reverse iterator. <var>seq</var> must be an object which
supports the sequence protocol (the __len__() method and the
<tt class="method">__getitem__()</tt> method with integer arguments starting at
<code>0</code>).
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-62' xml:id='l2h-62' class="function">round</tt></b>(</nobr></td>
<td><var>x</var><big>[</big><var>, n</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the floating point value <var>x</var> rounded to <var>n</var> digits
after the decimal point. If <var>n</var> is omitted, it defaults to zero.
The result is a floating point number. Values are rounded to the
closest multiple of 10 to the power minus <var>n</var>; if two multiples
are equally close, rounding is done away from 0 (so. for example,
<code>round(0.5)</code> is <code>1.0</code> and <code>round(-0.5)</code> is <code>-1.0</code>).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-63' xml:id='l2h-63' class="function">set</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>iterable</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a set whose elements are taken from <var>iterable</var>. The elements
must be immutable. To represent sets of sets, the inner sets should
be <tt class="class">frozenset</tt> objects. If <var>iterable</var> is not specified,
returns a new empty set, <code>set([])</code>.
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-64' xml:id='l2h-64' class="function">setattr</tt></b>(</nobr></td>
<td><var>object, name, value</var>)</td></tr></table></dt>
<dd>
This is the counterpart of <tt class="function">getattr()</tt>. The arguments are an
object, a string and an arbitrary value. The string may name an
existing attribute or a new attribute. The function assigns the
value to the attribute, provided the object allows it. For example,
<code>setattr(<var>x</var>, '<var>foobar</var>', 123)</code> is equivalent to
<code><var>x</var>.<var>foobar</var> = 123</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-65' xml:id='l2h-65' class="function">slice</tt></b>(</nobr></td>
<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>
<dd>
Return a slice object representing the set of indices specified by
<code>range(<var>start</var>, <var>stop</var>, <var>step</var>)</code>. The <var>start</var>
and <var>step</var> arguments default to <code>None</code>. Slice objects have
read-only data attributes <tt class="member">start</tt>, <tt class="member">stop</tt> and
<tt class="member">step</tt> which merely return the argument values (or their
default). They have no other explicit functionality; however they
are used by Numerical Python<a id='l2h-84' xml:id='l2h-84'></a> and other third
party extensions. Slice objects are also generated when extended
indexing syntax is used. For example: "<tt class="samp">a[start:stop:step]</tt>" or
"<tt class="samp">a[start:stop, i]</tt>".
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-66' xml:id='l2h-66' class="function">sorted</tt></b>(</nobr></td>
<td><var>iterable</var><big>[</big><var>, cmp</var><big>[</big><var>,
key</var><big>[</big><var>, reverse</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a new sorted list from the items in <var>iterable</var>.
The optional arguments <var>cmp</var>, <var>key</var>, and <var>reverse</var>
have the same meaning as those for the <tt class="method">list.sort()</tt> method.
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-67' xml:id='l2h-67' class="function">staticmethod</tt></b>(</nobr></td>
<td><var>function</var>)</td></tr></table></dt>
<dd>
Return a static method for <var>function</var>.
<P>
A static method does not receive an implicit first argument.
To declare a static method, use this idiom:
<P>
<div class="verbatim"><pre>
class C:
@staticmethod
def f(arg1, arg2, ...): ...
</pre></div>
<P>
The <code>@staticmethod</code> form is a function decorator - see the description
of function definitions in chapter 7 of the
<em class="citetitle"><a
href="../ref/ref.html"
title="Python Reference Manual"
>Python Reference Manual</a></em> for details.
<P>
It can be called either on the class (such as <code>C.f()</code>) or on an
instance (such as <code>C().f()</code>). The instance is ignored except
for its class.
<P>
Static methods in Python are similar to those found in Java or C++.
For a more advanced concept, see <tt class="function">classmethod()</tt> in this
section.
<span class="versionnote">New in version 2.2.</span>
<span class="versionnote">Changed in version 2.4:
Function decorator syntax added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-68' xml:id='l2h-68' class="function">str</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a string containing a nicely printable representation of an
object. For strings, this returns the string itself. The
difference with <code>repr(<var>object</var>)</code> is that
<code>str(<var>object</var>)</code> does not always attempt to return a string
that is acceptable to <tt class="function">eval()</tt>; its goal is to return a
printable string. If no argument is given, returns the empty
string, <code>''</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-69' xml:id='l2h-69' class="function">sum</tt></b>(</nobr></td>
<td><var>sequence</var><big>[</big><var>, start</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Sums <var>start</var> and the items of a <var>sequence</var>, from left to
right, and returns the total. <var>start</var> defaults to <code>0</code>.
The <var>sequence</var>'s items are normally numbers, and are not allowed
to be strings. The fast, correct way to concatenate sequence of
strings is by calling <code>''.join(<var>sequence</var>)</code>.
Note that <code>sum(range(<var>n</var>), <var>m</var>)</code> is equivalent to
<code>reduce(operator.add, range(<var>n</var>), <var>m</var>)</code>
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-70' xml:id='l2h-70' class="function">super</tt></b>(</nobr></td>
<td><var>type</var><big>[</big><var>, object-or-type</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the superclass of <var>type</var>. If the second argument is omitted
the super object returned is unbound. If the second argument is an
object, <code>isinstance(<var>obj</var>, <var>type</var>)</code> must be true. If
the second argument is a type, <code>issubclass(<var>type2</var>,
<var>type</var>)</code> must be true.
<tt class="function">super()</tt> only works for new-style classes.
<P>
A typical use for calling a cooperative superclass method is:
<div class="verbatim"><pre>
class C(B):
def meth(self, arg):
super(C, self).meth(arg)
</pre></div>
<P>
Note that <tt class="function">super</tt> is implemented as part of the binding process for
explicit dotted attribute lookups such as
"<tt class="samp">super(C, self).__getitem__(name)</tt>". Accordingly, <tt class="function">super</tt> is
undefined for implicit lookups using statements or operators such as
"<tt class="samp">super(C, self)[name]</tt>".
<span class="versionnote">New in version 2.2.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-71' xml:id='l2h-71' class="function">tuple</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>sequence</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a tuple whose items are the same and in the same order as
<var>sequence</var>'s items. <var>sequence</var> may be a sequence, a
container that supports iteration, or an iterator object.
If <var>sequence</var> is already a tuple, it
is returned unchanged. For instance, <code>tuple('abc')</code> returns
<code>('a', 'b', 'c')</code> and <code>tuple([1, 2, 3])</code> returns
<code>(1, 2, 3)</code>. If no argument is given, returns a new empty
tuple, <code>()</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-72' xml:id='l2h-72' class="function">type</tt></b>(</nobr></td>
<td><var>object</var>)</td></tr></table></dt>
<dd>
Return the type of an <var>object</var>. The return value is a
type<a id='l2h-73' xml:id='l2h-73'></a> object. The <tt class="function">isinstance()</tt> built-in
function is recommended for testing the type of an object.
<P>
With three arguments, <tt class="function">type</tt> functions as a constructor
as detailed below.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-74' xml:id='l2h-74' class="function">type</tt></b>(</nobr></td>
<td><var>name, bases, dict</var>)</td></tr></table></dt>
<dd>
Return a new type object. This is essentially a dynamic form of the
<tt class="keyword">class</tt> statement. The <var>name</var> string is the class name
and becomes the <tt class="member">__name__</tt> attribute; the <var>bases</var> tuple
itemizes the base classes and becomes the <tt class="member">__bases__</tt>
attribute; and the <var>dict</var> dictionary is the namespace containing
definitions for class body and becomes the <tt class="member">__dict__</tt>
attribute. For example, the following two statements create
identical <tt class="class">type</tt> objects:
<P>
<div class="verbatim"><pre>
&gt;&gt;&gt; class X(object):
... a = 1
...
&gt;&gt;&gt; X = type('X', (object,), dict(a=1))
</pre></div>
<span class="versionnote">New in version 2.2.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-75' xml:id='l2h-75' class="function">unichr</tt></b>(</nobr></td>
<td><var>i</var>)</td></tr></table></dt>
<dd>
Return the Unicode string of one character whose Unicode code is the
integer <var>i</var>. For example, <code>unichr(97)</code> returns the string
<code>u'a'</code>. This is the inverse of <tt class="function">ord()</tt> for Unicode
strings. The valid range for the argument depends how Python was
configured - it may be either UCS2 [0..0xFFFF] or UCS4 [0..0x10FFFF].
<tt class="exception">ValueError</tt> is raised otherwise.
<span class="versionnote">New in version 2.0.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-76' xml:id='l2h-76' class="function">unicode</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>object</var><big>[</big><var>, encoding
</var><big>[</big><var>, errors</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the Unicode string version of <var>object</var> using one of the
following modes:
<P>
If <var>encoding</var> and/or <var>errors</var> are given, <code>unicode()</code>
will decode the object which can either be an 8-bit string or a
character buffer using the codec for <var>encoding</var>. The
<var>encoding</var> parameter is a string giving the name of an encoding;
if the encoding is not known, <tt class="exception">LookupError</tt> is raised.
Error handling is done according to <var>errors</var>; this specifies the
treatment of characters which are invalid in the input encoding. If
<var>errors</var> is <code>'strict'</code> (the default), a
<tt class="exception">ValueError</tt> is raised on errors, while a value of
<code>'ignore'</code> causes errors to be silently ignored, and a value of
<code>'replace'</code> causes the official Unicode replacement character,
<code>U+FFFD</code>, to be used to replace input characters which cannot
be decoded. See also the <tt class="module"><a href="module-codecs.html">codecs</a></tt> module.
<P>
If no optional parameters are given, <code>unicode()</code> will mimic the
behaviour of <code>str()</code> except that it returns Unicode strings
instead of 8-bit strings. More precisely, if <var>object</var> is a
Unicode string or subclass it will return that Unicode string without
any additional decoding applied.
<P>
For objects which provide a <tt class="method">__unicode__()</tt> method, it will
call this method without arguments to create a Unicode string. For
all other objects, the 8-bit string version or representation is
requested and then converted to a Unicode string using the codec for
the default encoding in <code>'strict'</code> mode.
<P>
<span class="versionnote">New in version 2.0.</span>
<span class="versionnote">Changed in version 2.2:
Support for <tt class="method">__unicode__()</tt> added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-77' xml:id='l2h-77' class="function">vars</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>object</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Without arguments, return a dictionary corresponding to the current
local symbol table. With a module, class or class instance object
as argument (or anything else that has a <tt class="member">__dict__</tt>
attribute), returns a dictionary corresponding to the object's
symbol table. The returned dictionary should not be modified: the
effects on the corresponding symbol table are undefined.<A NAME="tex2html4"
HREF="#foot996"><SUP>2.4</SUP></A></dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-78' xml:id='l2h-78' class="function">xrange</tt></b>(</nobr></td>
<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>
<dd>
This function is very similar to <tt class="function">range()</tt>, but returns an
``xrange object'' instead of a list. This is an opaque sequence
type which yields the same values as the corresponding list, without
actually storing them all simultaneously. The advantage of
<tt class="function">xrange()</tt> over <tt class="function">range()</tt> is minimal (since
<tt class="function">xrange()</tt> still has to create the values when asked for
them) except when a very large range is used on a memory-starved
machine or when all of the range's elements are never used (such as
when the loop is usually terminated with <tt class="keyword">break</tt>).
<P>
<span class="note"><b class="label">Note:</b>
<tt class="function">xrange()</tt> is intended to be simple and fast.
Implementations may impose restrictions to achieve this.
The C implementation of Python restricts all arguments to
native C longs ("short" Python integers), and also requires
that the number of elements fit in a native C long.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-79' xml:id='l2h-79' class="function">zip</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>iterable, ...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function returns a list of tuples, where the <var>i</var>-th tuple contains
the <var>i</var>-th element from each of the argument sequences or iterables.
The returned list is truncated in length to the length of
the shortest argument sequence. When there are multiple arguments
which are all of the same length, <tt class="function">zip()</tt> is
similar to <tt class="function">map()</tt> with an initial argument of <code>None</code>.
With a single sequence argument, it returns a list of 1-tuples.
With no arguments, it returns an empty list.
<span class="versionnote">New in version 2.0.</span>
<P>
<span class="versionnote">Changed in version 2.4:
Formerly, <tt class="function">zip()</tt> required at least one argument
and <code>zip()</code> raised a <tt class="exception">TypeError</tt> instead of returning
an empty list..</span>
</dl>
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
<DT><A NAME="foot394">... module.</A><A
href="built-in-funcs.html#tex2html2"><SUP>2.2</SUP></A></DT>
<DD>It is used relatively
rarely so does not warrant being made into a statement.
</DD>
<DT><A NAME="foot1090">... used.</A><A
href="built-in-funcs.html#tex2html3"><SUP>2.3</SUP></A></DT>
<DD>
Specifying a buffer size currently has no effect on systems that
don't have <tt class="cfunction">setvbuf()</tt>. The interface to specify the
buffer size is not done using a method that calls
<tt class="cfunction">setvbuf()</tt>, because that may dump core when called
after any I/O has been performed, and there's no reliable way to
determine whether this is the case.
</DD>
<DT><A NAME="foot996">... undefined.</A><A
href="built-in-funcs.html#tex2html4"><SUP>2.4</SUP></A></DT>
<DD>
In the current implementation, local variable bindings cannot
normally be affected this way, but variables retrieved from
other scopes (such as modules) can be. This may change.
</DD>
</DL>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="2. Built-In Objects"
href="builtin.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="2. Built-In Objects"
href="builtin.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="2.2 Non-essential Built-in Functions"
href="non-essential-built-in-funcs.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="builtin.html">2. Built-In Objects</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="builtin.html">2. Built-In Objects</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="non-essential-built-in-funcs.html">2.2 Non-essential Built-in Functions</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>