"Make small changes, but carry a big diff."

Minor local consistency adjustments.
A couple of small tweaks to the setdlopenflags() description.
For setprofile() and settrace(), convert some references to become
hyperlinks in the HTML version.
This commit is contained in:
Fred Drake 2001-07-18 17:52:58 +00:00
parent 1a2302b3b2
commit 72182027a8
1 changed files with 240 additions and 241 deletions

View File

@ -11,13 +11,12 @@ It is always available.
\begin{datadesc}{argv} \begin{datadesc}{argv}
The list of command line arguments passed to a Python script. The list of command line arguments passed to a Python script.
\code{argv[0]} is the script name (it is operating system \code{argv[0]} is the script name (it is operating system dependent
dependent whether this is a full pathname or not). whether this is a full pathname or not). If the command was
If the command was executed using the \programopt{-c} command line executed using the \programopt{-c} command line option to the
option to the interpreter, \code{argv[0]} is set to the string interpreter, \code{argv[0]} is set to the string \code{'-c'}. If no
\code{'-c'}. script name was passed to the Python interpreter, \code{argv} has
If no script name was passed to the Python interpreter, zero length.
\code{argv} has zero length.
\end{datadesc} \end{datadesc}
\begin{datadesc}{byteorder} \begin{datadesc}{byteorder}
@ -36,82 +35,81 @@ It is always available.
\end{datadesc} \end{datadesc}
\begin{datadesc}{copyright} \begin{datadesc}{copyright}
A string containing the copyright pertaining to the Python interpreter. A string containing the copyright pertaining to the Python
interpreter.
\end{datadesc} \end{datadesc}
\begin{datadesc}{dllhandle} \begin{datadesc}{dllhandle}
Integer specifying the handle of the Python DLL. Integer specifying the handle of the Python DLL.
Availability: Windows. Availability: Windows.
\end{datadesc} \end{datadesc}
\begin{funcdesc}{displayhook}{\var{value}} \begin{funcdesc}{displayhook}{\var{value}}
If \var{value} is not \code{None}, this function prints it to If \var{value} is not \code{None}, this function prints it to
\code{sys.stdout}, and saves it in \code{__builtin__._}. \code{sys.stdout}, and saves it in \code{__builtin__._}.
\code{sys.displayhook} is called on the result of evaluating \code{sys.displayhook} is called on the result of evaluating an
an expression entered in an interactive Python session. expression entered in an interactive Python session. The display of
The display of these values can be customized by assigning these values can be customized by assigning another one-argument
another one-argument function to \code{sys.displayhook}. function to \code{sys.displayhook}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{excepthook}{\var{type}, \var{value}, \var{traceback}} \begin{funcdesc}{excepthook}{\var{type}, \var{value}, \var{traceback}}
This function prints out a given traceback and exception to This function prints out a given traceback and exception to
\code{sys.stderr}. \code{sys.stderr}.
When an exception is raised and uncaught, the interpreter calls When an exception is raised and uncaught, the interpreter calls
\code{sys.excepthook} with three arguments, the exception class, \code{sys.excepthook} with three arguments, the exception class,
exception instance, and a traceback object. exception instance, and a traceback object. In an interactive
In an interactive session this happens just before session this happens just before control is returned to the prompt;
control is returned to the prompt; in a Python program this happens in a Python program this happens just before the program exits. The
just before the program exits. handling of such top-level exceptions can be customized by assigning
The handling of such top-level exceptions can be customized by another three-argument function to \code{sys.excepthook}.
assigning another three-argument function to \code{sys.excepthook}.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{__displayhook__} \begin{datadesc}{__displayhook__}
\dataline{__excepthook__} \dataline{__excepthook__}
These objects contain the original values of \code{displayhook} These objects contain the original values of \code{displayhook} and
and \code{excepthook} at the start of the program. They are saved \code{excepthook} at the start of the program. They are saved so
so that \code{displayhook} and \code{excepthook} can be restored that \code{displayhook} and \code{excepthook} can be restored in
in case they happen to get replaced with broken objects. case they happen to get replaced with broken objects.
\end{datadesc} \end{datadesc}
\begin{funcdesc}{exc_info}{} \begin{funcdesc}{exc_info}{}
This function returns a tuple of three values that give information This function returns a tuple of three values that give information
about the exception that is currently being handled. The information about the exception that is currently being handled. The
returned is specific both to the current thread and to the current information returned is specific both to the current thread and to
stack frame. If the current stack frame is not handling an exception, the current stack frame. If the current stack frame is not handling
the information is taken from the calling stack frame, or its caller, an exception, the information is taken from the calling stack frame,
and so on until a stack frame is found that is handling an exception. or its caller, and so on until a stack frame is found that is
Here, ``handling an exception'' is defined as ``executing or having handling an exception. Here, ``handling an exception'' is defined
executed an except clause.'' For any stack frame, only as ``executing or having executed an except clause.'' For any stack
information about the most recently handled exception is accessible. frame, only information about the most recently handled exception is
accessible.
If no exception is being handled anywhere on the stack, a tuple If no exception is being handled anywhere on the stack, a tuple
containing three \code{None} values is returned. Otherwise, the containing three \code{None} values is returned. Otherwise, the
values returned are values returned are \code{(\var{type}, \var{value},
\code{(\var{type}, \var{value}, \var{traceback})}. \var{traceback})}. Their meaning is: \var{type} gets the exception
Their meaning is: \var{type} gets the exception type of the exception type of the exception being handled (a string or class object);
being handled (a string or class object); \var{value} gets the \var{value} gets the exception parameter (its \dfn{associated value}
exception parameter (its \dfn{associated value} or the second argument or the second argument to \keyword{raise}, which is always a class
to \keyword{raise}, which is always a class instance if the exception instance if the exception type is a class object); \var{traceback}
type is a class object); \var{traceback} gets a traceback object (see gets a traceback object (see the Reference Manual) which
the Reference Manual) which encapsulates the call stack at the point encapsulates the call stack at the point where the exception
where the exception originally occurred. originally occurred. \obindex{traceback}
\obindex{traceback}
\strong{Warning:} assigning the \var{traceback} return value to a \strong{Warning:} assigning the \var{traceback} return value to a
local variable in a function that is handling an exception will cause local variable in a function that is handling an exception will
a circular reference. This will prevent anything referenced by a local cause a circular reference. This will prevent anything referenced
variable in the same function or by the traceback from being garbage by a local variable in the same function or by the traceback from
collected. Since most functions don't need access to the traceback, being garbage collected. Since most functions don't need access to
the best solution is to use something like the traceback, the best solution is to use something like
\code{type, value = sys.exc_info()[:2]} \code{type, value = sys.exc_info()[:2]} to extract only the
to extract only the exception type and value. If you do need the exception type and value. If you do need the traceback, make sure
traceback, make sure to delete it after use (best done with a to delete it after use (best done with a \keyword{try}
\keyword{try} ... \keyword{finally} statement) or to call ... \keyword{finally} statement) or to call \function{exc_info()} in
\function{exc_info()} in a function that does not itself handle an a function that does not itself handle an exception.
exception.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{exc_type} \begin{datadesc}{exc_type}
@ -119,59 +117,61 @@ exception.
\dataline{exc_traceback} \dataline{exc_traceback}
\deprecated {1.5} \deprecated {1.5}
{Use \function{exc_info()} instead.} {Use \function{exc_info()} instead.}
Since they are global variables, they are not specific to the current Since they are global variables, they are not specific to the
thread, so their use is not safe in a multi-threaded program. When no current thread, so their use is not safe in a multi-threaded
exception is being handled, \code{exc_type} is set to \code{None} and program. When no exception is being handled, \code{exc_type} is set
the other two are undefined. to \code{None} and the other two are undefined.
\end{datadesc} \end{datadesc}
\begin{datadesc}{exec_prefix} \begin{datadesc}{exec_prefix}
A string giving the site-specific directory prefix where the A string giving the site-specific directory prefix where the
platform-dependent Python files are installed; by default, this is platform-dependent Python files are installed; by default, this is
also \code{'/usr/local'}. This can be set at build time with the also \code{'/usr/local'}. This can be set at build time with the
\longprogramopt{exec-prefix} argument to the \longprogramopt{exec-prefix} argument to the \program{configure}
\program{configure} script. Specifically, all configuration files script. Specifically, all configuration files (e.g. the
(e.g. the \file{config.h} header file) are installed in the directory \file{config.h} header file) are installed in the directory
\code{exec_prefix + '/lib/python\var{version}/config'}, and shared \code{exec_prefix + '/lib/python\var{version}/config'}, and shared
library modules are installed in \code{exec_prefix + library modules are installed in \code{exec_prefix +
'/lib/python\var{version}/lib-dynload'}, where \var{version} is equal '/lib/python\var{version}/lib-dynload'}, where \var{version} is
to \code{version[:3]}. equal to \code{version[:3]}.
\end{datadesc} \end{datadesc}
\begin{datadesc}{executable} \begin{datadesc}{executable}
A string giving the name of the executable binary for the Python A string giving the name of the executable binary for the Python
interpreter, on systems where this makes sense. interpreter, on systems where this makes sense.
\end{datadesc} \end{datadesc}
\begin{funcdesc}{exit}{\optional{arg}} \begin{funcdesc}{exit}{\optional{arg}}
Exit from Python. This is implemented by raising the Exit from Python. This is implemented by raising the
\exception{SystemExit} exception, so cleanup actions specified by \exception{SystemExit} exception, so cleanup actions specified by
finally clauses of \keyword{try} statements are honored, and it is finally clauses of \keyword{try} statements are honored, and it is
possible to intercept the exit attempt at an outer level. The possible to intercept the exit attempt at an outer level. The
optional argument \var{arg} can be an integer giving the exit status optional argument \var{arg} can be an integer giving the exit status
(defaulting to zero), or another type of object. If it is an integer, (defaulting to zero), or another type of object. If it is an
zero is considered ``successful termination'' and any nonzero value is integer, zero is considered ``successful termination'' and any
considered ``abnormal termination'' by shells and the like. Most nonzero value is considered ``abnormal termination'' by shells and
systems require it to be in the range 0-127, and produce undefined the like. Most systems require it to be in the range 0-127, and
results otherwise. Some systems have a convention for assigning produce undefined results otherwise. Some systems have a convention
specific meanings to specific exit codes, but these are generally for assigning specific meanings to specific exit codes, but these
underdeveloped; Unix programs generally use 2 for command line syntax are generally underdeveloped; Unix programs generally use 2 for
errors and 1 for all other kind of errors. If another type of object command line syntax errors and 1 for all other kind of errors. If
is passed, \code{None} is equivalent to passing zero, and any other another type of object is passed, \code{None} is equivalent to
object is printed to \code{sys.stderr} and results in an exit code of passing zero, and any other object is printed to \code{sys.stderr}
1. In particular, \code{sys.exit("some error message")} is a quick and results in an exit code of 1. In particular,
way to exit a program when an error occurs. \code{sys.exit("some error message")} is a quick way to exit a
program when an error occurs.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{exitfunc} \begin{datadesc}{exitfunc}
This value is not actually defined by the module, but can be set by 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 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 exit. When set, it should be a parameterless function. This
will be called when the interpreter exits. Only one function may be function will be called when the interpreter exits. Only one
installed in this way; to allow multiple functions which will be called function may be installed in this way; to allow multiple functions
at termination, use the \refmodule{atexit} module. Note: the exit function which will be called at termination, use the \refmodule{atexit}
is not called when the program is killed by a signal, when a Python module. Note: the exit function is not called when the program is
fatal internal error is detected, or when \code{os._exit()} is called. killed by a signal, when a Python fatal internal error is detected,
or when \code{os._exit()} is called.
\end{datadesc} \end{datadesc}
\begin{funcdesc}{getdefaultencoding}{} \begin{funcdesc}{getdefaultencoding}{}
@ -189,34 +189,35 @@ way to exit a program when an error occurs.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getrefcount}{object} \begin{funcdesc}{getrefcount}{object}
Return the reference count of the \var{object}. The count returned is Return the reference count of the \var{object}. The count returned
generally one higher than you might expect, because it includes the is generally one higher than you might expect, because it includes
(temporary) reference as an argument to \function{getrefcount()}. the (temporary) reference as an argument to
\function{getrefcount()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{getrecursionlimit}{} \begin{funcdesc}{getrecursionlimit}{}
Return the current value of the recursion limit, the maximum depth of Return the current value of the recursion limit, the maximum depth
the Python interpreter stack. This limit prevents infinite recursion of the Python interpreter stack. This limit prevents infinite
from causing an overflow of the C stack and crashing Python. It can recursion from causing an overflow of the C stack and crashing
be set by \function{setrecursionlimit()}. Python. It can be set by \function{setrecursionlimit()}.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{_getframe}{\optional{depth}} \begin{funcdesc}{_getframe}{\optional{depth}}
Return a frame object from the call stack. If optional integer Return a frame object from the call stack. If optional integer
\var{depth} is given, return the frame object that many calls below \var{depth} is given, return the frame object that many calls below
the top of the stack. If that is deeper than the call stack, the top of the stack. If that is deeper than the call stack,
\exception{ValueError} is raised. The default for \var{depth} is \exception{ValueError} is raised. The default for \var{depth} is
zero, returning the frame at the top of the call stack. zero, returning the frame at the top of the call stack.
This function should be used for internal and specialized This function should be used for internal and specialized purposes
purposes only. only.
\end{funcdesc} \end{funcdesc}
\begin{datadesc}{hexversion} \begin{datadesc}{hexversion}
The version number encoded as a single integer. This is guaranteed to The version number encoded as a single integer. This is guaranteed
increase with each version, including proper support for to increase with each version, including proper support for
non-production releases. For example, to test that the Python non-production releases. For example, to test that the Python
interpreter is at least version 1.5.2, use: interpreter is at least version 1.5.2, use:
\begin{verbatim} \begin{verbatim}
if sys.hexversion >= 0x010502F0: if sys.hexversion >= 0x010502F0:
@ -227,37 +228,36 @@ else:
... ...
\end{verbatim} \end{verbatim}
This is called \samp{hexversion} since it only really looks meaningful This is called \samp{hexversion} since it only really looks
when viewed as the result of passing it to the built-in meaningful when viewed as the result of passing it to the built-in
\function{hex()} function. The \code{version_info} value may be used \function{hex()} function. The \code{version_info} value may be
for a more human-friendly encoding of the same information. used for a more human-friendly encoding of the same information.
\versionadded{1.5.2} \versionadded{1.5.2}
\end{datadesc} \end{datadesc}
\begin{datadesc}{last_type} \begin{datadesc}{last_type}
\dataline{last_value} \dataline{last_value}
\dataline{last_traceback} \dataline{last_traceback}
These three variables are not always defined; they are set when an These three variables are not always defined; they are set when an
exception is not handled and the interpreter prints an error message exception is not handled and the interpreter prints an error message
and a stack traceback. Their intended use is to allow an interactive and a stack traceback. Their intended use is to allow an
user to import a debugger module and engage in post-mortem debugging interactive user to import a debugger module and engage in
without having to re-execute the command that caused the error. post-mortem debugging without having to re-execute the command that
(Typical use is \samp{import pdb; pdb.pm()} to enter the post-mortem caused the error. (Typical use is \samp{import pdb; pdb.pm()} to
debugger; see the chapter ``The Python Debugger'' for more enter the post-mortem debugger; see chapter \ref{debugger}, ``The
information.) Python Debugger,'' for more information.)
\refstmodindex{pdb}
The meaning of the variables is the same The meaning of the variables is the same as that of the return
as that of the return values from \function{exc_info()} above. values from \function{exc_info()} above. (Since there is only one
(Since there is only one interactive thread, thread-safety is not a interactive thread, thread-safety is not a concern for these
concern for these variables, unlike for \code{exc_type} etc.) variables, unlike for \code{exc_type} etc.)
\end{datadesc} \end{datadesc}
\begin{datadesc}{maxint} \begin{datadesc}{maxint}
The largest positive integer supported by Python's regular integer The largest positive integer supported by Python's regular integer
type. This is at least 2**31-1. The largest negative integer is type. This is at least 2**31-1. The largest negative integer is
\code{-maxint-1} -- the asymmetry results from the use of 2's \code{-maxint-1} -- the asymmetry results from the use of 2's
complement binary arithmetic. complement binary arithmetic.
\end{datadesc} \end{datadesc}
\begin{datadesc}{modules} \begin{datadesc}{modules}
@ -273,35 +273,34 @@ complement binary arithmetic.
\indexiii{module}{search}{path} \indexiii{module}{search}{path}
A list of strings that specifies the search path for modules. A list of strings that specifies the search path for modules.
Initialized from the environment variable \envvar{PYTHONPATH}, or an Initialized from the environment variable \envvar{PYTHONPATH}, or an
installation-dependent default. installation-dependent default.
The first item of this list, \code{path[0]}, is the The first item of this list, \code{path[0]}, is the directory
directory containing the script that was used to invoke the Python containing the script that was used to invoke the Python
interpreter. If the script directory is not available (e.g. if the interpreter. If the script directory is not available (e.g. if the
interpreter is invoked interactively or if the script is read from interpreter is invoked interactively or if the script is read from
standard input), \code{path[0]} is the empty string, which directs standard input), \code{path[0]} is the empty string, which directs
Python to search modules in the current directory first. Notice that Python to search modules in the current directory first. Notice
the script directory is inserted \emph{before} the entries inserted as that the script directory is inserted \emph{before} the entries
a result of \envvar{PYTHONPATH}. inserted as a result of \envvar{PYTHONPATH}.
\end{datadesc} \end{datadesc}
\begin{datadesc}{platform} \begin{datadesc}{platform}
This string contains a platform identifier, e.g. \code{'sunos5'} or This string contains a platform identifier, e.g. \code{'sunos5'} or
\code{'linux1'}. This can be used to append platform-specific \code{'linux1'}. This can be used to append platform-specific
components to \code{path}, for instance. components to \code{path}, for instance.
\end{datadesc} \end{datadesc}
\begin{datadesc}{prefix} \begin{datadesc}{prefix}
A string giving the site-specific directory prefix where the platform A string giving the site-specific directory prefix where the
independent Python files are installed; by default, this is the string platform independent Python files are installed; by default, this is
\code{'/usr/local'}. This can be set at build time with the the string \code{'/usr/local'}. This can be set at build time with
\longprogramopt{prefix} argument to the the \longprogramopt{prefix} argument to the \program{configure}
\program{configure} script. The main collection of Python library script. The main collection of Python library modules is installed
modules is installed in the directory \code{prefix + in the directory \code{prefix + '/lib/python\var{version}'} while
'/lib/python\var{version}'} while the platform independent header the platform independent header files (all except \file{config.h})
files (all except \file{config.h}) are stored in \code{prefix + are stored in \code{prefix + '/include/python\var{version}'}, where
'/include/python\var{version}'}, where \var{version} is equal to \var{version} is equal to \code{version[:3]}.
\code{version[:3]}.
\end{datadesc} \end{datadesc}
\begin{datadesc}{ps1} \begin{datadesc}{ps1}
@ -311,20 +310,20 @@ files (all except \file{config.h}) are stored in \code{prefix +
Strings specifying the primary and secondary prompt of the Strings specifying the primary and secondary prompt of the
interpreter. These are only defined if the interpreter is in interpreter. These are only defined if the interpreter is in
interactive mode. Their initial values in this case are interactive mode. Their initial values in this case are
\code{'>\code{>}> '} and \code{'... '}. If a non-string object is assigned \code{'>\code{>}> '} and \code{'... '}. If a non-string object is
to either variable, its \function{str()} is re-evaluated each time assigned to either variable, its \function{str()} is re-evaluated
the interpreter prepares to read a new interactive command; this can each time the interpreter prepares to read a new interactive
be used to implement a dynamic prompt. command; this can be used to implement a dynamic prompt.
\end{datadesc} \end{datadesc}
\begin{funcdesc}{setcheckinterval}{interval} \begin{funcdesc}{setcheckinterval}{interval}
Set the interpreter's ``check interval''. This integer value Set the interpreter's ``check interval''. This integer value
determines how often the interpreter checks for periodic things such determines how often the interpreter checks for periodic things such
as thread switches and signal handlers. The default is \code{10}, meaning as thread switches and signal handlers. The default is \code{10},
the check is performed every 10 Python virtual instructions. Setting meaning the check is performed every 10 Python virtual instructions.
it to a larger value may increase performance for programs using Setting it to a larger value may increase performance for programs
threads. Setting it to a value \code{<=} 0 checks every virtual instruction, using threads. Setting it to a value \code{<=} 0 checks every
maximizing responsiveness as well as overhead. virtual instruction, maximizing responsiveness as well as overhead.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setdefaultencoding}{name} \begin{funcdesc}{setdefaultencoding}{name}
@ -347,91 +346,91 @@ maximizing responsiveness as well as overhead.
other things, this will enable a lazy resolving of symbols when other things, this will enable a lazy resolving of symbols when
imporing a module, if called as \code{sys.setdlopenflags(0)}. To imporing a module, if called as \code{sys.setdlopenflags(0)}. To
share symols across extension modules, call as share symols across extension modules, call as
\code{sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)}. Symbolic \code{sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL)}. Symbolic
names for the flag modules can be either found in the \refmodule{dl} names for the flag modules can be either found in the \refmodule{dl}
module, or in the \module{DLFCN} module. If \module{DLFCN} is not module, or in the \module{DLFCN} module. If \module{DLFCN} is not
available, it can be generated from \code{/usr/include/dlfcn.h} available, it can be generated from \file{/usr/include/dlfcn.h}
using the \code{h2py} script. using the \program{h2py} script.
Availability: \UNIX. Availability: \UNIX.
\versionadded{2.2} \versionadded{2.2}
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{setprofile}{profilefunc} \begin{funcdesc}{setprofile}{profilefunc}
Set the system's profile function, which allows you to implement a Set the system's profile function,\index{profile function} which
Python source code profiler in Python. See the chapter on the allows you to implement a Python source code profiler in
Python Profiler. The system's profile function Python.\index{profiler} See chapter \ref{profile} for more
information on the Python profiler. The system's profile function
is called similarly to the system's trace function (see is called similarly to the system's trace function (see
\function{settrace()}), but it isn't called for each executed line of \function{settrace()}), but it isn't called for each executed line
code (only on call and return and when an exception occurs). Also, of code (only on call and return and when an exception occurs).
its return value is not used, so it can just return \code{None}. Also, its return value is not used, so it can simply return
\code{None}.
\end{funcdesc} \end{funcdesc}
\index{profile function}
\index{profiler}
\begin{funcdesc}{setrecursionlimit}{limit} \begin{funcdesc}{setrecursionlimit}{limit}
Set the maximum depth of the Python interpreter stack to \var{limit}. Set the maximum depth of the Python interpreter stack to
This limit prevents infinite recursion from causing an overflow of the \var{limit}. This limit prevents infinite recursion from causing an
C stack and crashing Python. overflow of the C stack and crashing Python.
The highest possible limit is platform-dependent. A user may need to The highest possible limit is platform-dependent. A user may need
set the limit higher when she has a program that requires deep 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 recursion and a platform that supports a higher limit. This should
done with care, because a too-high limit can lead to a crash. be done with care, because a too-high limit can lead to a crash.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{settrace}{tracefunc} \begin{funcdesc}{settrace}{tracefunc}
Set the system's trace function, which allows you to implement a Set the system's trace function,\index{trace function} which allows
Python source code debugger in Python. See section ``How It Works'' you to implement a Python source code debugger in Python. See
in the chapter on the Python Debugger. section \ref{debugger-hooks}, ``How It Works,'' in the chapter on
the Python debugger.\index{debugger}
\end{funcdesc} \end{funcdesc}
\index{trace function}
\index{debugger}
\begin{datadesc}{stdin} \begin{datadesc}{stdin}
\dataline{stdout} \dataline{stdout}
\dataline{stderr} \dataline{stderr}
File objects corresponding to the interpreter's standard input, File objects corresponding to the interpreter's standard input,
output and error streams. \code{stdin} is used for all output and error streams. \code{stdin} is used for all interpreter
interpreter input except for scripts but including calls to input except for scripts but including calls to
\function{input()}\bifuncindex{input} and \function{input()}\bifuncindex{input} and
\function{raw_input()}\bifuncindex{raw_input}. \code{stdout} is used \function{raw_input()}\bifuncindex{raw_input}. \code{stdout} is
for the output of \keyword{print} and expression statements and for the used for the output of \keyword{print} and expression statements and
prompts of \function{input()} and \function{raw_input()}. The interpreter's for the prompts of \function{input()} and \function{raw_input()}.
own prompts and (almost all of) its error messages go to The interpreter's own prompts and (almost all of) its error messages
\code{stderr}. \code{stdout} and \code{stderr} needn't go to \code{stderr}. \code{stdout} and \code{stderr} needn't be
be built-in file objects: any object is acceptable as long as it has built-in file objects: any object is acceptable as long as it has a
a \method{write()} method that takes a string argument. (Changing these \method{write()} method that takes a string argument. (Changing
objects doesn't affect the standard I/O streams of processes these objects doesn't affect the standard I/O streams of processes
executed by \function{os.popen()}, \function{os.system()} or the executed by \function{os.popen()}, \function{os.system()} or the
\function{exec*()} family of functions in the \refmodule{os} module.) \function{exec*()} family of functions in the \refmodule{os}
\refstmodindex{os} module.)
\end{datadesc} \end{datadesc}
\begin{datadesc}{__stdin__} \begin{datadesc}{__stdin__}
\dataline{__stdout__} \dataline{__stdout__}
\dataline{__stderr__} \dataline{__stderr__}
These objects contain the original values of \code{stdin}, These objects contain the original values of \code{stdin},
\code{stderr} and \code{stdout} at the start of the program. They are \code{stderr} and \code{stdout} at the start of the program. They
used during finalization, and could be useful to restore the actual are used during finalization, and could be useful to restore the
files to known working file objects in case they have been overwritten actual files to known working file objects in case they have been
with a broken object. overwritten with a broken object.
\end{datadesc} \end{datadesc}
\begin{datadesc}{tracebacklimit} \begin{datadesc}{tracebacklimit}
When this variable is set to an integer value, it determines the When this variable is set to an integer value, it determines the
maximum number of levels of traceback information printed when an maximum number of levels of traceback information printed when an
unhandled exception occurs. The default is \code{1000}. When set to unhandled exception occurs. The default is \code{1000}. When set
0 or less, all traceback information is suppressed and only the to \code{0} or less, all traceback information is suppressed and
exception type and value are printed. only the exception type and value are printed.
\end{datadesc} \end{datadesc}
\begin{datadesc}{version} \begin{datadesc}{version}
A string containing the version number of the Python interpreter plus A string containing the version number of the Python interpreter
additional information on the build number and compiler used. It has plus additional information on the build number and compiler used.
a value of the form \code{'\var{version} (\#\var{build_number}, It has a value of the form \code{'\var{version}
\var{build_date}, \var{build_time}) [\var{compiler}]'}. The first (\#\var{build_number}, \var{build_date}, \var{build_time})
three characters are used to identify the version in the installation [\var{compiler}]'}. The first three characters are used to identify
directories (where appropriate on each platform). An example: the version in the installation directories (where appropriate on
each platform). An example:
\begin{verbatim} \begin{verbatim}
>>> import sys >>> import sys
@ -441,22 +440,22 @@ directories (where appropriate on each platform). An example:
\end{datadesc} \end{datadesc}
\begin{datadesc}{version_info} \begin{datadesc}{version_info}
A tuple containing the five components of the version number: A tuple containing the five components of the version number:
\var{major}, \var{minor}, \var{micro}, \var{releaselevel}, and \var{major}, \var{minor}, \var{micro}, \var{releaselevel}, and
\var{serial}. All values except \var{releaselevel} are integers; the \var{serial}. All values except \var{releaselevel} are integers;
release level is \code{'alpha'}, \code{'beta'}, the release level is \code{'alpha'}, \code{'beta'},
\code{'candidate'}, or \code{'final'}. The \code{version_info} value \code{'candidate'}, or \code{'final'}. The \code{version_info}
corresponding to the Python version 2.0 is value corresponding to the Python version 2.0 is \code{(2, 0, 0,
\code{(2, 0, 0, 'final', 0)}. 'final', 0)}.
\versionadded{2.0} \versionadded{2.0}
\end{datadesc} \end{datadesc}
\begin{datadesc}{winver} \begin{datadesc}{winver}
The version number used to form registry keys on Windows platforms. The version number used to form registry keys on Windows platforms.
This is stored as string resource 1000 in the Python DLL. The value This is stored as string resource 1000 in the Python DLL. The value
is normally the first three characters of \constant{version}. It is is normally the first three characters of \constant{version}. It is
provided in the \module{sys} module for informational purposes; provided in the \module{sys} module for informational purposes;
modifying this value has no effect on the registry keys used by modifying this value has no effect on the registry keys used by
Python. Python.
Availability: Windows. Availability: Windows.
\end{datadesc} \end{datadesc}