Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / module-sys.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="module-gc.html" />
<link rel="prev" href="python.html" />
<link rel="parent" href="python.html" />
<link rel="next" href="module-gc.html" />
<meta name='aesop' content='information' />
<title>3.1 sys -- System-specific parameters and 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="3. Python Runtime Services"
href="python.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="3. Python Runtime Services"
href="python.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="3.2 gc "
href="module-gc.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="python.html">3. Python Runtime Services</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-gc.html">3.2 gc </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION005100000000000000000">
3.1 <tt class="module">sys</tt> --
System-specific parameters and functions</A>
</H1>
<P>
<A NAME="module-sys"></A>
<P>
This module provides access to some variables used or maintained by the
interpreter and to functions that interact strongly with the interpreter.
It is always available.
<P>
<dl><dt><b><tt id='l2h-329' xml:id='l2h-329'>argv</tt></b></dt>
<dd>
The list of command line arguments passed to a Python script.
<code>argv[0]</code> is the script name (it is operating system dependent
whether this is a full pathname or not). If the command was
executed using the <b class="programopt">-c</b> command line option to the
interpreter, <code>argv[0]</code> is set to the string <code>'-c'</code>. If no
script name was passed to the Python interpreter, <code>argv</code> has
zero length.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-330' xml:id='l2h-330'>byteorder</tt></b></dt>
<dd>
An indicator of the native byte order. This will have the value
<code>'big'</code> on big-endian (most-signigicant byte first) platforms,
and <code>'little'</code> on little-endian (least-significant byte first)
platforms.
<span class="versionnote">New in version 2.0.</span>
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-331' xml:id='l2h-331'>builtin_module_names</tt></b></dt>
<dd>
A tuple of strings giving the names of all modules that are compiled
into this Python interpreter. (This information is not available in
any other way -- <code>modules.keys()</code> only lists the imported
modules.)
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-332' xml:id='l2h-332'>copyright</tt></b></dt>
<dd>
A string containing the copyright pertaining to the Python
interpreter.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-333' xml:id='l2h-333'>dllhandle</tt></b></dt>
<dd>
Integer specifying the handle of the Python DLL.
Availability: Windows.
</dd></dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-334' xml:id='l2h-334' class="function">displayhook</tt></b>(</nobr></td>
<td><var><var>value</var></var>)</td></tr></table></dt>
<dd>
If <var>value</var> is not <code>None</code>, this function prints it to
<code>sys.stdout</code>, and saves it in <code>__builtin__._</code>.
<P>
<code>sys.displayhook</code> is called on the result of evaluating an
expression entered in an interactive Python session. The display of
these values can be customized by assigning another one-argument
function to <code>sys.displayhook</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-335' xml:id='l2h-335' class="function">excepthook</tt></b>(</nobr></td>
<td><var><var>type</var>, <var>value</var>, <var>traceback</var></var>)</td></tr></table></dt>
<dd>
This function prints out a given traceback and exception to
<code>sys.stderr</code>.
<P>
When an exception is raised and uncaught, the interpreter calls
<code>sys.excepthook</code> with three arguments, the exception class,
exception instance, and a traceback object. In an interactive
session this happens just before control is returned to the prompt;
in a Python program this happens just before the program exits. The
handling of such top-level exceptions can be customized by assigning
another three-argument function to <code>sys.excepthook</code>.
</dl>
<P>
<dl><dt><b><tt id='l2h-336' xml:id='l2h-336'>__displayhook__</tt></b></dt>
<dd>
<dt><b><tt id='l2h-381' xml:id='l2h-381'>__excepthook__</tt></b></dt><dd>
These objects contain the original values of <code>displayhook</code> and
<code>excepthook</code> at the start of the program. They are saved so
that <code>displayhook</code> and <code>excepthook</code> can be restored in
case they happen to get replaced with broken objects.
</dd></dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-337' xml:id='l2h-337' class="function">exc_info</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This function returns a tuple of three values that give information
about the exception that is currently being handled. The
information returned is specific both to the current thread and to
the current stack frame. If the current stack frame is not handling
an exception, the information is taken from the calling stack frame,
or its caller, and so on until a stack frame is found that is
handling an exception. Here, ``handling an exception'' is defined
as ``executing or having executed an except clause.'' For any stack
frame, only information about the most recently handled exception is
accessible.
<P>
If no exception is being handled anywhere on the stack, a tuple
containing three <code>None</code> values is returned. Otherwise, the
values returned are <code>(<var>type</var>, <var>value</var>,
<var>traceback</var>)</code>. Their meaning is: <var>type</var> gets the exception
type of the exception being handled (a class object);
<var>value</var> gets the exception parameter (its <i class="dfn">associated value</i>
or the second argument to <tt class="keyword">raise</tt>, which is always a class
instance if the exception type is a class object); <var>traceback</var>
gets a traceback object (see the Reference Manual) which
encapsulates the call stack at the point where the exception
originally occurred. <a id='l2h-338' xml:id='l2h-338'></a>
<P>
If <tt class="function">exc_clear()</tt> is called, this function will return three
<code>None</code> values until either another exception is raised in the
current thread or the execution stack returns to a frame where
another exception is being handled.
<P>
<span class="warning"><b class="label">Warning:</b>
Assigning the <var>traceback</var> return value to a
local variable in a function that is handling an exception will
cause a circular reference. This will prevent anything referenced
by a local variable in the same function or by the traceback from
being garbage collected. Since most functions don't need access to
the traceback, the best solution is to use something like
<code>exctype, value = sys.exc_info()[:2]</code> to extract only the
exception type and value. If you do need the traceback, make sure
to delete it after use (best done with a <tt class="keyword">try</tt>
... <tt class="keyword">finally</tt> statement) or to call <tt class="function">exc_info()</tt> in
a function that does not itself handle an exception.</span> <span class="note"><b class="label">Note:</b>
Beginning
with Python 2.2, such cycles are automatically reclaimed when garbage
collection is enabled and they become unreachable, but it remains more
efficient to avoid creating cycles.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-339' xml:id='l2h-339' class="function">exc_clear</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This function clears all information relating to the current or last
exception that occurred in the current thread. After calling this
function, <tt class="function">exc_info()</tt> will return three <code>None</code> values until
another exception is raised in the current thread or the execution stack
returns to a frame where another exception is being handled.
<P>
This function is only needed in only a few obscure situations. These
include logging and error handling systems that report information on the
last or current exception. This function can also be used to try to free
resources and trigger object finalization, though no guarantee is made as
to what objects will be freed, if any.
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-340' xml:id='l2h-340'>exc_type</tt></b></dt>
<dd>
<dt><b><tt id='l2h-382' xml:id='l2h-382'>exc_value</tt></b></dt><dd>
<dt><b><tt id='l2h-383' xml:id='l2h-383'>exc_traceback</tt></b></dt><dd>
<div class="versionnote"><b>Deprecated since release 1.5.</b>
Use <tt class="function">exc_info()</tt> instead.</div><p></p>
Since they are global variables, they are not specific to the
current thread, so their use is not safe in a multi-threaded
program. When no exception is being handled, <code>exc_type</code> is set
to <code>None</code> and the other two are undefined.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-341' xml:id='l2h-341'>exec_prefix</tt></b></dt>
<dd>
A string giving the site-specific directory prefix where the
platform-dependent Python files are installed; by default, this is
also <code>'/usr/local'</code>. This can be set at build time with the
<b class="programopt">--exec-prefix</b> argument to the <b class="program">configure</b>
script. Specifically, all configuration files (e.g. the
<span class="file">pyconfig.h</span> header file) are installed in the directory
<code>exec_prefix + '/lib/python<var>version</var>/config'</code>, and shared
library modules are installed in <code>exec_prefix +
'/lib/python<var>version</var>/lib-dynload'</code>, where <var>version</var> is
equal to <code>version[:3]</code>.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-342' xml:id='l2h-342'>executable</tt></b></dt>
<dd>
A string giving the name of the executable binary for the Python
interpreter, on systems where this makes sense.
</dd></dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-343' xml:id='l2h-343' class="function">exit</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>arg</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Exit from Python. This is implemented by raising the
<tt class="exception">SystemExit</tt> exception, so cleanup actions specified by
finally clauses of <tt class="keyword">try</tt> statements are honored, and it is
possible to intercept the exit attempt at an outer level. The
optional argument <var>arg</var> can be an integer giving the exit status
(defaulting to zero), or another type of object. If it is an
integer, zero is considered ``successful termination'' and any
nonzero value is considered ``abnormal termination'' by shells and
the like. Most systems require it to be in the range 0-127, and
produce undefined results otherwise. Some systems have a convention
for assigning specific meanings to specific exit codes, but these
are generally underdeveloped; <span class="Unix">Unix</span> programs generally use 2 for
command line syntax errors and 1 for all other kind of errors. If
another type of object is passed, <code>None</code> is equivalent to
passing zero, and any other object is printed to <code>sys.stderr</code>
and results in an exit code of 1. In particular,
<code>sys.exit("some error message")</code> is a quick way to exit a
program when an error occurs.
</dl>
<P>
<dl><dt><b><tt id='l2h-344' xml:id='l2h-344'>exitfunc</tt></b></dt>
<dd>
This value is not actually defined by the module, but can be set by
the user (or by a program) to specify a clean-up action at program
exit. When set, it should be a parameterless function. This
function will be called when the interpreter exits. Only one
function may be installed in this way; to allow multiple functions
which will be called at termination, use the <tt class="module"><a href="module-atexit.html">atexit</a></tt>
module. <span class="note"><b class="label">Note:</b>
The exit function is not called when the program is
killed by a signal, when a Python fatal internal error is detected,
or when <code>os._exit()</code> is called.</span>
<div class="versionnote"><b>Deprecated since release 2.4.</b>
Use <tt class="module"><a href="module-atexit.html">atexit</a></tt> instead.</div><p></p>
</dd></dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-345' xml:id='l2h-345' class="function">getcheckinterval</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the interpreter's ``check interval'';
see <tt class="function">setcheckinterval()</tt>.
<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-346' xml:id='l2h-346' class="function">getdefaultencoding</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the name of the current default string encoding used by the
Unicode implementation.
<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-347' xml:id='l2h-347' class="function">getdlopenflags</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the current value of the flags that are used for
<tt class="cfunction">dlopen()</tt> calls. The flag constants are defined in the
<tt class="module"><a href="module-dl.html">dl</a></tt> and <tt class="module">DLFCN</tt> modules.
Availability: <span class="Unix">Unix</span>.
<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-348' xml:id='l2h-348' class="function">getfilesystemencoding</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the name of the encoding used to convert Unicode filenames
into system file names, or <code>None</code> if the system default encoding
is used. The result value depends on the operating system:
<UL>
<LI>On Windows 9x, the encoding is ``mbcs''.
</LI>
<LI>On Mac OS X, the encoding is ``utf-8''.
</LI>
<LI>On Unix, the encoding is the user's preference
according to the result of nl_langinfo(CODESET), or None if
the nl_langinfo(CODESET) failed.
</LI>
<LI>On Windows NT+, file names are Unicode natively, so no conversion
is performed. <code>getfilesystemencoding</code> still returns ``mbcs'',
as this is the encoding that applications should use when they
explicitly want to convert Unicode strings to byte strings that
are equivalent when used as file names.
</LI>
</UL>
<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-349' xml:id='l2h-349' class="function">getrefcount</tt></b>(</nobr></td>
<td><var>object</var>)</td></tr></table></dt>
<dd>
Return the reference count of the <var>object</var>. The count returned
is generally one higher than you might expect, because it includes
the (temporary) reference as an argument to
<tt class="function">getrefcount()</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-350' xml:id='l2h-350' class="function">getrecursionlimit</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return the current value of the recursion limit, the maximum depth
of the Python interpreter stack. This limit prevents infinite
recursion from causing an overflow of the C stack and crashing
Python. It can be set by <tt class="function">setrecursionlimit()</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-351' xml:id='l2h-351' class="function">_getframe</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>depth</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a frame object from the call stack. If optional integer
<var>depth</var> is given, return the frame object that many calls below
the top of the stack. If that is deeper than the call stack,
<tt class="exception">ValueError</tt> is raised. The default for <var>depth</var> is
zero, returning the frame at the top of the call stack.
<P>
This function should be used for internal and specialized purposes
only.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-352' xml:id='l2h-352' class="function">getwindowsversion</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a tuple containing five components, describing the Windows
version currently running. The elements are <var>major</var>, <var>minor</var>,
<var>build</var>, <var>platform</var>, and <var>text</var>. <var>text</var> contains
a string while all other values are integers.
<P>
<var>platform</var> may be one of the following values:
<P>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Constant</th>
<th class="left" >Platform</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><tt class="constant">VER_PLATFORM_WIN32s</tt></td>
<td class="left" >Win32s on Windows 3.1</td></tr>
<tr><td class="left" valign="baseline"><tt class="constant">VER_PLATFORM_WIN32_WINDOWS</tt></td>
<td class="left" >Windows 95/98/ME</td></tr>
<tr><td class="left" valign="baseline"><tt class="constant">VER_PLATFORM_WIN32_NT</tt></td>
<td class="left" >Windows NT/2000/XP</td></tr>
<tr><td class="left" valign="baseline"><tt class="constant">VER_PLATFORM_WIN32_CE</tt></td>
<td class="left" >Windows CE</td></tr></tbody>
</table></div>
<P>
This function wraps the Win32 <tt class="cfunction">GetVersionEx()</tt> function;
see the Microsoft documentation for more information about these
fields.
<P>
Availability: Windows.
<span class="versionnote">New in version 2.3.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-353' xml:id='l2h-353'>hexversion</tt></b></dt>
<dd>
The version number encoded as a single integer. This is guaranteed
to increase with each version, including proper support for
non-production releases. For example, to test that the Python
interpreter is at least version 1.5.2, use:
<P>
<div class="verbatim"><pre>
if sys.hexversion &gt;= 0x010502F0:
# use some advanced feature
...
else:
# use an alternative implementation or warn the user
...
</pre></div>
<P>
This is called "<tt class="samp">hexversion</tt>" since it only really looks
meaningful when viewed as the result of passing it to the built-in
<tt class="function">hex()</tt> function. The <code>version_info</code> value may be
used for a more human-friendly encoding of the same information.
<span class="versionnote">New in version 1.5.2.</span>
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-354' xml:id='l2h-354'>last_type</tt></b></dt>
<dd>
<dt><b><tt id='l2h-384' xml:id='l2h-384'>last_value</tt></b></dt><dd>
<dt><b><tt id='l2h-385' xml:id='l2h-385'>last_traceback</tt></b></dt><dd>
These three variables are not always defined; they are set when an
exception is not handled and the interpreter prints an error message
and a stack traceback. Their intended use is to allow an
interactive user to import a debugger module and engage in
post-mortem debugging without having to re-execute the command that
caused the error. (Typical use is "<tt class="samp">import pdb; pdb.pm()</tt>" to
enter the post-mortem debugger; see chapter&nbsp;<A href="module-pdb.html#debugger">9</A>, ``The
Python Debugger,'' for more information.)
<P>
The meaning of the variables is the same as that of the return
values from <tt class="function">exc_info()</tt> above. (Since there is only one
interactive thread, thread-safety is not a concern for these
variables, unlike for <code>exc_type</code> etc.)
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-355' xml:id='l2h-355'>maxint</tt></b></dt>
<dd>
The largest positive integer supported by Python's regular integer
type. This is at least 2**31-1. The largest negative integer is
<code>-maxint-1</code> -- the asymmetry results from the use of 2's
complement binary arithmetic.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-356' xml:id='l2h-356'>maxunicode</tt></b></dt>
<dd>
An integer giving the largest supported code point for a Unicode
character. The value of this depends on the configuration option
that specifies whether Unicode characters are stored as UCS-2 or
UCS-4.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-357' xml:id='l2h-357'>modules</tt></b></dt>
<dd>
This is a dictionary that maps module names to modules which have
already been loaded. This can be manipulated to force reloading of
modules and other tricks. Note that removing a module from this
dictionary is <em>not</em> the same as calling
<tt class="function">reload()</tt><a id='l2h-358' xml:id='l2h-358'></a> on the corresponding module
object.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-359' xml:id='l2h-359'>path</tt></b></dt>
<dd>
<a id='l2h-360' xml:id='l2h-360'></a> A list of strings that specifies the search path for modules.
Initialized from the environment variable <a class="envvar" id='l2h-386' xml:id='l2h-386'>PYTHONPATH</a>, plus an
installation-dependent default.
<P>
As initialized upon program startup,
the first item of this list, <code>path[0]</code>, is the directory
containing the script that was used to invoke the Python
interpreter. If the script directory is not available (e.g. if the
interpreter is invoked interactively or if the script is read from
standard input), <code>path[0]</code> is the empty string, which directs
Python to search modules in the current directory first. Notice
that the script directory is inserted <em>before</em> the entries
inserted as a result of <a class="envvar" id='l2h-387' xml:id='l2h-387'>PYTHONPATH</a>.
<P>
A program is free to modify this list for its own purposes.
<P>
<span class="versionnote">Changed in version 2.3:
Unicode strings are no longer ignored.</span>
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-361' xml:id='l2h-361'>platform</tt></b></dt>
<dd>
This string contains a platform identifier, e.g. <code>'sunos5'</code> or
<code>'linux1'</code>. This can be used to append platform-specific
components to <code>path</code>, for instance.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-362' xml:id='l2h-362'>prefix</tt></b></dt>
<dd>
A string giving the site-specific directory prefix where the
platform independent Python files are installed; by default, this is
the string <code>'/usr/local'</code>. This can be set at build time with
the <b class="programopt">--prefix</b> argument to the <b class="program">configure</b>
script. The main collection of Python library modules is installed
in the directory <code>prefix + '/lib/python<var>version</var>'</code> while
the platform independent header files (all except <span class="file">pyconfig.h</span>)
are stored in <code>prefix + '/include/python<var>version</var>'</code>, where
<var>version</var> is equal to <code>version[:3]</code>.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-363' xml:id='l2h-363'>ps1</tt></b></dt>
<dd>
<dt><b><tt id='l2h-388' xml:id='l2h-388'>ps2</tt></b></dt><dd>
<a id='l2h-389' xml:id='l2h-389'></a>
Strings specifying the primary and secondary prompt of the
interpreter. These are only defined if the interpreter is in
interactive mode. Their initial values in this case are
<code>'&gt;<code>&gt;</code>&gt; '</code> and <code>'... '</code>. If a non-string object is
assigned to either variable, its <tt class="function">str()</tt> is re-evaluated
each time the interpreter prepares to read a new interactive
command; this can be used to implement a dynamic prompt.
</dd></dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-364' xml:id='l2h-364' class="function">setcheckinterval</tt></b>(</nobr></td>
<td><var>interval</var>)</td></tr></table></dt>
<dd>
Set the interpreter's ``check interval''. This integer value
determines how often the interpreter checks for periodic things such
as thread switches and signal handlers. The default is <code>100</code>,
meaning the check is performed every 100 Python virtual instructions.
Setting it to a larger value may increase performance for programs
using threads. Setting it to a value <code>&lt;=</code> 0 checks every
virtual instruction, maximizing responsiveness as well as overhead.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-365' xml:id='l2h-365' class="function">setdefaultencoding</tt></b>(</nobr></td>
<td><var>name</var>)</td></tr></table></dt>
<dd>
Set the current default string encoding used by the Unicode
implementation. If <var>name</var> does not match any available
encoding, <tt class="exception">LookupError</tt> is raised. This function is only
intended to be used by the <tt class="module"><a href="module-site.html">site</a></tt> module implementation
and, where needed, by <tt class="module">sitecustomize</tt>. Once used by the
<tt class="module"><a href="module-site.html">site</a></tt> module, it is removed from the <tt class="module">sys</tt>
module's namespace.
<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-366' xml:id='l2h-366' class="function">setdlopenflags</tt></b>(</nobr></td>
<td><var>n</var>)</td></tr></table></dt>
<dd>
Set the flags used by the interpreter for <tt class="cfunction">dlopen()</tt>
calls, such as when the interpreter loads extension modules. Among
other things, this will enable a lazy resolving of symbols when
importing a module, if called as <code>sys.setdlopenflags(0)</code>. To
share symbols across extension modules, call as
<code>sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL)</code>. Symbolic
names for the flag modules can be either found in the <tt class="module"><a href="module-dl.html">dl</a></tt>
module, or in the <tt class="module">DLFCN</tt> module. If <tt class="module">DLFCN</tt> is not
available, it can be generated from <span class="file">/usr/include/dlfcn.h</span>
using the <b class="program">h2py</b> script.
Availability: <span class="Unix">Unix</span>.
<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-367' xml:id='l2h-367' class="function">setprofile</tt></b>(</nobr></td>
<td><var>profilefunc</var>)</td></tr></table></dt>
<dd>
Set the system's profile function,<a id='l2h-390' xml:id='l2h-390'></a> which
allows you to implement a Python source code profiler in
Python.<a id='l2h-391' xml:id='l2h-391'></a> See chapter&nbsp;<A href="profile.html#profile">10</A> for more
information on the Python profiler. The system's profile function
is called similarly to the system's trace function (see
<tt class="function">settrace()</tt>), but it isn't called for each executed line
of code (only on call and return, but the return event is reported
even when an exception has been set). The function is
thread-specific, but there is no way for the profiler to know about
context switches between threads, so it does not make sense to use
this in the presence of multiple threads.
Also, its return value is not used, so it can simply return
<code>None</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-368' xml:id='l2h-368' class="function">setrecursionlimit</tt></b>(</nobr></td>
<td><var>limit</var>)</td></tr></table></dt>
<dd>
Set the maximum depth of the Python interpreter stack to
<var>limit</var>. This limit prevents infinite recursion from causing an
overflow of the C stack and crashing Python.
<P>
The highest possible limit is platform-dependent. A user may need
to set the limit higher when she has a program that requires deep
recursion and a platform that supports a higher limit. This should
be done with care, because a too-high limit can lead to a crash.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-369' xml:id='l2h-369' class="function">settrace</tt></b>(</nobr></td>
<td><var>tracefunc</var>)</td></tr></table></dt>
<dd>
Set the system's trace function,<a id='l2h-392' xml:id='l2h-392'></a> which allows
you to implement a Python source code debugger in Python. See
section <A href="debugger-hooks.html#debugger-hooks">9.2</A>, ``How It Works,'' in the chapter on
the Python debugger.<a id='l2h-393' xml:id='l2h-393'></a> The function is
thread-specific; for a debugger to support multiple threads, it must
be registered using <tt class="function">settrace()</tt> for each thread being
debugged. <span class="note"><b class="label">Note:</b>
The <tt class="function">settrace()</tt> function is intended only
for implementing debuggers, profilers, coverage tools and the like.
Its behavior is part of the implementation platform, rather than
part of the language definition, and thus may not be available in
all Python implementations.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-370' xml:id='l2h-370' class="function">settscdump</tt></b>(</nobr></td>
<td><var>on_flag</var>)</td></tr></table></dt>
<dd>
Activate dumping of VM measurements using the Pentium timestamp
counter, if <var>on_flag</var> is true. Deactivate these dumps if
<var>on_flag</var> is off. The function is available only if Python
was compiled with <b class="programopt">--with-tsc</b>. To understand the
output of this dump, read <span class="file">Python/ceval.c</span> in the Python
sources.
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><b><tt id='l2h-371' xml:id='l2h-371'>stdin</tt></b></dt>
<dd>
<dt><b><tt id='l2h-394' xml:id='l2h-394'>stdout</tt></b></dt><dd>
<dt><b><tt id='l2h-395' xml:id='l2h-395'>stderr</tt></b></dt><dd>
File objects corresponding to the interpreter's standard input,
output and error streams. <code>stdin</code> is used for all interpreter
input except for scripts but including calls to
<tt class="function">input()</tt><a id='l2h-372' xml:id='l2h-372'></a> and
<tt class="function">raw_input()</tt><a id='l2h-373' xml:id='l2h-373'></a>. <code>stdout</code> is
used for the output of <tt class="keyword">print</tt> and expression statements and
for the prompts of <tt class="function">input()</tt> and <tt class="function">raw_input()</tt>.
The interpreter's own prompts and (almost all of) its error messages
go to <code>stderr</code>. <code>stdout</code> and <code>stderr</code> needn't be
built-in file objects: any object is acceptable as long as it has a
<tt class="method">write()</tt> method that takes a string argument. (Changing
these objects doesn't affect the standard I/O streams of processes
executed by <tt class="function">os.popen()</tt>, <tt class="function">os.system()</tt> or the
<tt class="function">exec*()</tt> family of functions in the <tt class="module"><a href="module-os.html">os</a></tt>
module.)
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-374' xml:id='l2h-374'>__stdin__</tt></b></dt>
<dd>
<dt><b><tt id='l2h-396' xml:id='l2h-396'>__stdout__</tt></b></dt><dd>
<dt><b><tt id='l2h-397' xml:id='l2h-397'>__stderr__</tt></b></dt><dd>
These objects contain the original values of <code>stdin</code>,
<code>stderr</code> and <code>stdout</code> at the start of the program. They
are used during finalization, and could be useful to restore the
actual files to known working file objects in case they have been
overwritten with a broken object.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-375' xml:id='l2h-375'>tracebacklimit</tt></b></dt>
<dd>
When this variable is set to an integer value, it determines the
maximum number of levels of traceback information printed when an
unhandled exception occurs. The default is <code>1000</code>. When set
to <code>0</code> or less, all traceback information is suppressed and
only the exception type and value are printed.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-376' xml:id='l2h-376'>version</tt></b></dt>
<dd>
A string containing the version number of the Python interpreter
plus additional information on the build number and compiler used.
It has a value of the form <code>'<var>version</var>
(#<var>build_number</var>, <var>build_date</var>, <var>build_time</var>)
[<var>compiler</var>]'</code>. The first three characters are used to identify
the version in the installation directories (where appropriate on
each platform). An example:
<P>
<div class="verbatim"><pre>
&gt;&gt;&gt; import sys
&gt;&gt;&gt; sys.version
'1.5.2 (#0 Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)]'
</pre></div>
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-377' xml:id='l2h-377'>api_version</tt></b></dt>
<dd>
The C API version for this interpreter. Programmers may find this useful
when debugging version conflicts between Python and extension
modules.
<span class="versionnote">New in version 2.3.</span>
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-378' xml:id='l2h-378'>version_info</tt></b></dt>
<dd>
A tuple containing the five components of the version number:
<var>major</var>, <var>minor</var>, <var>micro</var>, <var>releaselevel</var>, and
<var>serial</var>. All values except <var>releaselevel</var> are integers;
the release level is <code>'alpha'</code>, <code>'beta'</code>,
<code>'candidate'</code>, or <code>'final'</code>. The <code>version_info</code>
value corresponding to the Python version 2.0 is <code>(2, 0, 0,
'final', 0)</code>.
<span class="versionnote">New in version 2.0.</span>
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-379' xml:id='l2h-379'>warnoptions</tt></b></dt>
<dd>
This is an implementation detail of the warnings framework; do not
modify this value. Refer to the <tt class="module"><a href="module-warnings.html">warnings</a></tt> module for
more information on the warnings framework.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-380' xml:id='l2h-380'>winver</tt></b></dt>
<dd>
The version number used to form registry keys on Windows platforms.
This is stored as string resource 1000 in the Python DLL. The value
is normally the first three characters of <tt class="constant">version</tt>. It is
provided in the <tt class="module">sys</tt> module for informational purposes;
modifying this value has no effect on the registry keys used by
Python.
Availability: Windows.
</dd></dl>
<P>
<div class="seealso">
<p class="heading">See Also:</p>
<dl compact="compact" class="seemodule">
<dt>Module <b><tt class="module"><a href="module-site.html">site</a></tt>:</b>
<dd>This describes how to use .pth files to extend <code>sys.path</code>.
</dl>
</div>
<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="3. Python Runtime Services"
href="python.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="3. Python Runtime Services"
href="python.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="3.2 gc "
href="module-gc.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="python.html">3. Python Runtime Services</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-gc.html">3.2 gc </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>