blob: 44b785373866b1bdc1e4bdb617c4e4046481df92 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{sys} ---
Fred Drakeffbe6871999-04-22 21:23:22 +00002 System-specific parameters and functions}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00003
Fred Drakeffbe6871999-04-22 21:23:22 +00004\declaremodule{builtin}{sys}
Fred Drake295da241998-08-10 19:42:37 +00005\modulesynopsis{Access system-specific parameters and functions.}
Fred Drakeb91e9341998-07-23 17:59:49 +00006
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00007This module provides access to some variables used or maintained by the
8interpreter and to functions that interact strongly with the interpreter.
9It is always available.
10
Guido van Rossum470be141995-03-17 16:07:09 +000011
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000012\begin{datadesc}{argv}
13 The list of command line arguments passed to a Python script.
Fred Drake0fd72ee1998-03-08 05:43:51 +000014 \code{argv[0]} is the script name (it is operating system
Guido van Rossum470be141995-03-17 16:07:09 +000015 dependent whether this is a full pathname or not).
Fred Drake268df271999-11-09 19:45:59 +000016 If the command was executed using the \programopt{-c} command line
17 option to the interpreter, \code{argv[0]} is set to the string
Fred Drakeb91e9341998-07-23 17:59:49 +000018 \code{'-c'}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000019 If no script name was passed to the Python interpreter,
Fred Drake0fd72ee1998-03-08 05:43:51 +000020 \code{argv} has zero length.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000021\end{datadesc}
22
Fred Drakea2b6ad62000-08-15 04:24:43 +000023\begin{datadesc}{byteorder}
Fred Drake68e29152000-08-14 15:47:30 +000024 An indicator of the native byte order. This will have the value
25 \code{'big'} on big-endian (most-signigicant byte first) platforms,
26 and \code{'little'} on little-endian (least-significant byte first)
27 platforms.
28 \versionadded{2.0}
29\end{datadesc}
30
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000031\begin{datadesc}{builtin_module_names}
Guido van Rossum0d2971b1997-01-06 23:01:02 +000032 A tuple of strings giving the names of all modules that are compiled
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000033 into this Python interpreter. (This information is not available in
Fred Drake0fd72ee1998-03-08 05:43:51 +000034 any other way --- \code{modules.keys()} only lists the imported
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000035 modules.)
36\end{datadesc}
37
Guido van Rossum3e5fe421998-06-10 17:57:44 +000038\begin{datadesc}{copyright}
39A string containing the copyright pertaining to the Python interpreter.
40\end{datadesc}
41
Fred Drake38e5d272000-04-03 20:13:55 +000042\begin{datadesc}{dllhandle}
43Integer specifying the handle of the Python DLL.
44Availability: Windows.
45\end{datadesc}
46
Moshe Zadkaf68f2fe2001-01-11 05:41:27 +000047\begin{funcdesc}{displayhook}{\var{value}}
48If \var{value} is not \code{None}, this function prints it to
49\code{sys.stdout}, and saves it in \code{__builtin__._}.
50
Ka-Ping Yeeb5c51322001-03-23 02:46:52 +000051\code{sys.displayhook} is called on the result of evaluating
52an expression entered in an interactive Python session.
53The display of these values can be customized by assigning
54another function to \code{sys.displayhook}.
Moshe Zadkaf68f2fe2001-01-11 05:41:27 +000055\end{funcdesc}
56
Ka-Ping Yeeb5c51322001-03-23 02:46:52 +000057\begin{funcdesc}{excepthook}{\var{type}, \var{value}, \var{traceback}}
58This function prints out a given traceback and exception to
59\code{sys.stderr}.
60
61\code{sys.excepthook} is called when an exception is raised
62and uncaught. In an interactive session this happens just before
63control is returned to the prompt; in a Python program this happens
64just before the program exits.
65The handling of such top-level exceptions can be customized by
66assigning another function to \code{sys.excepthook}.
67\end{funcdesc}
68
69\begin{datadesc}{__displayhook__}
70\dataline{__excepthook__}
71These objects contain the original values of \code{displayhook}
72and \code{excepthook} at the start of the program. They are saved
73so that \code{displayhook} and \code{excepthook} can be restored
74in case they happen to get replaced with broken objects.
75\end{datadesc}
76
Guido van Rossum871cf161997-10-20 22:38:43 +000077\begin{funcdesc}{exc_info}{}
78This function returns a tuple of three values that give information
79about the exception that is currently being handled. The information
80returned is specific both to the current thread and to the current
81stack frame. If the current stack frame is not handling an exception,
82the information is taken from the calling stack frame, or its caller,
83and so on until a stack frame is found that is handling an exception.
84Here, ``handling an exception'' is defined as ``executing or having
Fred Drake0fd72ee1998-03-08 05:43:51 +000085executed an except clause.'' For any stack frame, only
Guido van Rossum871cf161997-10-20 22:38:43 +000086information about the most recently handled exception is accessible.
87
88If no exception is being handled anywhere on the stack, a tuple
89containing three \code{None} values is returned. Otherwise, the
90values returned are
91\code{(\var{type}, \var{value}, \var{traceback})}.
92Their meaning is: \var{type} gets the exception type of the exception
93being handled (a string or class object); \var{value} gets the
94exception parameter (its \dfn{associated value} or the second argument
Fred Drake0fd72ee1998-03-08 05:43:51 +000095to \keyword{raise}, which is always a class instance if the exception
Guido van Rossum871cf161997-10-20 22:38:43 +000096type is a class object); \var{traceback} gets a traceback object (see
97the Reference Manual) which encapsulates the call stack at the point
98where the exception originally occurred.
99\obindex{traceback}
100
101\strong{Warning:} assigning the \var{traceback} return value to a
102local variable in a function that is handling an exception will cause
103a circular reference. This will prevent anything referenced by a local
104variable in the same function or by the traceback from being garbage
105collected. Since most functions don't need access to the traceback,
106the best solution is to use something like
107\code{type, value = sys.exc_info()[:2]}
108to extract only the exception type and value. If you do need the
109traceback, make sure to delete it after use (best done with a
Fred Drake0fd72ee1998-03-08 05:43:51 +0000110\keyword{try} ... \keyword{finally} statement) or to call
111\function{exc_info()} in a function that does not itself handle an
112exception.
Guido van Rossum871cf161997-10-20 22:38:43 +0000113\end{funcdesc}
114
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000115\begin{datadesc}{exc_type}
116\dataline{exc_value}
117\dataline{exc_traceback}
Fred Drake0fd72ee1998-03-08 05:43:51 +0000118\deprecated {1.5}
119 {Use \function{exc_info()} instead.}
120Since they are global variables, they are not specific to the current
Guido van Rossum871cf161997-10-20 22:38:43 +0000121thread, so their use is not safe in a multi-threaded program. When no
Fred Drake0fd72ee1998-03-08 05:43:51 +0000122exception is being handled, \code{exc_type} is set to \code{None} and
123the other two are undefined.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000124\end{datadesc}
125
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000126\begin{datadesc}{exec_prefix}
Fred Drake268df271999-11-09 19:45:59 +0000127A string giving the site-specific directory prefix where the
128platform-dependent Python files are installed; by default, this is
129also \code{'/usr/local'}. This can be set at build time with the
Fred Drakeee775a12000-04-11 19:46:40 +0000130\longprogramopt{exec-prefix} argument to the
Fred Drake0fd72ee1998-03-08 05:43:51 +0000131\program{configure} script. Specifically, all configuration files
132(e.g. the \file{config.h} header file) are installed in the directory
Fred Drake268df271999-11-09 19:45:59 +0000133\code{exec_prefix + '/lib/python\var{version}/config'}, and shared
134library modules are installed in \code{exec_prefix +
135'/lib/python\var{version}/lib-dynload'}, where \var{version} is equal
136to \code{version[:3]}.
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000137\end{datadesc}
138
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000139\begin{datadesc}{executable}
140A string giving the name of the executable binary for the Python
141interpreter, on systems where this makes sense.
142\end{datadesc}
143
Guido van Rossum04307ce1998-11-23 17:49:53 +0000144\begin{funcdesc}{exit}{\optional{arg}}
145Exit from Python. This is implemented by raising the
146\exception{SystemExit} exception, so cleanup actions specified by
147finally clauses of \keyword{try} statements are honored, and it is
148possible to intercept the exit attempt at an outer level. The
149optional argument \var{arg} can be an integer giving the exit status
150(defaulting to zero), or another type of object. If it is an integer,
151zero is considered ``successful termination'' and any nonzero value is
152considered ``abnormal termination'' by shells and the like. Most
153systems require it to be in the range 0-127, and produce undefined
154results otherwise. Some systems have a convention for assigning
155specific meanings to specific exit codes, but these are generally
156underdeveloped; Unix programs generally use 2 for command line syntax
157errors and 1 for all other kind of errors. If another type of object
158is passed, \code{None} is equivalent to passing zero, and any other
159object is printed to \code{sys.stderr} and results in an exit code of
1601. In particular, \code{sys.exit("some error message")} is a quick
161way to exit a program when an error occurs.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000162\end{funcdesc}
163
164\begin{datadesc}{exitfunc}
165 This value is not actually defined by the module, but can be set by
166 the user (or by a program) to specify a clean-up action at program
167 exit. When set, it should be a parameterless function. This function
Fred Drakec19425d2000-06-28 15:07:31 +0000168 will be called when the interpreter exits. Only one function may be
169 installed in this way; to allow multiple functions which will be called
170 at termination, use the \refmodule{atexit} module. Note: the exit function
Guido van Rossum5fc9c861999-03-25 20:30:00 +0000171 is not called when the program is killed by a signal, when a Python
172 fatal internal error is detected, or when \code{os._exit()} is called.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000173\end{datadesc}
174
Fred Drake8940faf2000-10-25 21:02:55 +0000175\begin{funcdesc}{getdefaultencoding}{}
176 Return the name of the current default string encoding used by the
177 Unicode implementation.
178 \versionadded{2.0}
179\end{funcdesc}
180
Guido van Rossum6e91c6a1998-02-07 21:17:05 +0000181\begin{funcdesc}{getrefcount}{object}
182Return the reference count of the \var{object}. The count returned is
183generally one higher than you might expect, because it includes the
Fred Drakeb91e9341998-07-23 17:59:49 +0000184(temporary) reference as an argument to \function{getrefcount()}.
Guido van Rossum6e91c6a1998-02-07 21:17:05 +0000185\end{funcdesc}
186
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000187\begin{funcdesc}{getrecursionlimit}{}
188Return the current value of the recursion limit, the maximum depth of
189the Python interpreter stack. This limit prevents infinite recursion
190from causing an overflow of the C stack and crashing Python. It can
Fred Drake65faf112000-08-31 19:35:56 +0000191be set by \function{setrecursionlimit()}.
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000192\end{funcdesc}
193
Barry Warsawb6a54d22000-12-06 21:47:46 +0000194\begin{funcdesc}{_getframe}{\optional{depth}}
195Return a frame object from the call stack. If optional integer
196\var{depth} is given, return the frame object that many calls below
197the top of the stack. If that is deeper than the call stack,
198\exception{ValueError} is raised. The default for \var{depth} is
199zero, returning the frame at the top of the call stack.
200
201This function should be used for internal and specialized
202purposes only.
203\end{funcdesc}
204
Fred Drake4d65d732000-04-13 16:54:17 +0000205\begin{datadesc}{hexversion}
206The version number encoded as a single integer. This is guaranteed to
207increase with each version, including proper support for
208non-production releases. For example, to test that the Python
209interpreter is at least version 1.5.2, use:
210
211\begin{verbatim}
212if sys.hexversion >= 0x010502F0:
213 # use some advanced feature
214 ...
215else:
216 # use an alternative implementation or warn the user
217 ...
218\end{verbatim}
219
220This is called \samp{hexversion} since it only really looks meaningful
221when viewed as the result of passing it to the built-in
222\function{hex()} function. The \code{version_info} value may be used
223for a more human-friendly encoding of the same information.
224\versionadded{1.5.2}
225\end{datadesc}
226
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000227\begin{datadesc}{last_type}
228\dataline{last_value}
229\dataline{last_traceback}
Guido van Rossum871cf161997-10-20 22:38:43 +0000230These three variables are not always defined; they are set when an
231exception is not handled and the interpreter prints an error message
232and a stack traceback. Their intended use is to allow an interactive
233user to import a debugger module and engage in post-mortem debugging
234without having to re-execute the command that caused the error.
Fred Drake0fd72ee1998-03-08 05:43:51 +0000235(Typical use is \samp{import pdb; pdb.pm()} to enter the post-mortem
Guido van Rossum871cf161997-10-20 22:38:43 +0000236debugger; see the chapter ``The Python Debugger'' for more
237information.)
Fred Drake54820dc1997-12-15 21:56:05 +0000238\refstmodindex{pdb}
Guido van Rossum871cf161997-10-20 22:38:43 +0000239
240The meaning of the variables is the same
Fred Drake0fd72ee1998-03-08 05:43:51 +0000241as that of the return values from \function{exc_info()} above.
Guido van Rossum871cf161997-10-20 22:38:43 +0000242(Since there is only one interactive thread, thread-safety is not a
Fred Drake0fd72ee1998-03-08 05:43:51 +0000243concern for these variables, unlike for \code{exc_type} etc.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000244\end{datadesc}
245
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000246\begin{datadesc}{maxint}
247The largest positive integer supported by Python's regular integer
248type. This is at least 2**31-1. The largest negative integer is
249\code{-maxint-1} -- the asymmetry results from the use of 2's
250complement binary arithmetic.
251\end{datadesc}
252
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000253\begin{datadesc}{modules}
Fred Drake0fd72ee1998-03-08 05:43:51 +0000254 This is a dictionary that maps module names to modules which have
255 already been loaded. This can be manipulated to force reloading of
256 modules and other tricks. Note that removing a module from this
257 dictionary is \emph{not} the same as calling
258 \function{reload()}\bifuncindex{reload} on the corresponding module
259 object.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000260\end{datadesc}
261
262\begin{datadesc}{path}
Fred Drake2b67bee1998-01-13 18:35:51 +0000263\indexiii{module}{search}{path}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000264 A list of strings that specifies the search path for modules.
Fred Drakeb91e9341998-07-23 17:59:49 +0000265 Initialized from the environment variable \envvar{PYTHONPATH}, or an
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000266 installation-dependent default.
267
Fred Drake0fd72ee1998-03-08 05:43:51 +0000268The first item of this list, \code{path[0]}, is the
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000269directory containing the script that was used to invoke the Python
270interpreter. If the script directory is not available (e.g. if the
271interpreter is invoked interactively or if the script is read from
Fred Drake0fd72ee1998-03-08 05:43:51 +0000272standard input), \code{path[0]} is the empty string, which directs
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000273Python to search modules in the current directory first. Notice that
Fred Drake54820dc1997-12-15 21:56:05 +0000274the script directory is inserted \emph{before} the entries inserted as
Fred Drakeb91e9341998-07-23 17:59:49 +0000275a result of \envvar{PYTHONPATH}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000276\end{datadesc}
277
Guido van Rossum6b686e91995-07-07 23:00:35 +0000278\begin{datadesc}{platform}
Fred Drake0fd72ee1998-03-08 05:43:51 +0000279This string contains a platform identifier, e.g. \code{'sunos5'} or
280\code{'linux1'}. This can be used to append platform-specific
281components to \code{path}, for instance.
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000282\end{datadesc}
283
284\begin{datadesc}{prefix}
285A string giving the site-specific directory prefix where the platform
286independent Python files are installed; by default, this is the string
Fred Drakeb91e9341998-07-23 17:59:49 +0000287\code{'/usr/local'}. This can be set at build time with the
Fred Drakeee775a12000-04-11 19:46:40 +0000288\longprogramopt{prefix} argument to the
Fred Drake268df271999-11-09 19:45:59 +0000289\program{configure} script. The main collection of Python library
290modules is installed in the directory \code{prefix +
291'/lib/python\var{version}'} while the platform independent header
292files (all except \file{config.h}) are stored in \code{prefix +
293'/include/python\var{version}'}, where \var{version} is equal to
294\code{version[:3]}.
Guido van Rossum6b686e91995-07-07 23:00:35 +0000295\end{datadesc}
296
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000297\begin{datadesc}{ps1}
298\dataline{ps2}
Fred Drakee6cedb31998-04-03 07:05:16 +0000299\index{interpreter prompts}
300\index{prompts, interpreter}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000301 Strings specifying the primary and secondary prompt of the
302 interpreter. These are only defined if the interpreter is in
303 interactive mode. Their initial values in this case are
Fred Drake8940faf2000-10-25 21:02:55 +0000304 \code{'>\code{>}> '} and \code{'... '}. If a non-string object is assigned
Fred Drake0fd72ee1998-03-08 05:43:51 +0000305 to either variable, its \function{str()} is re-evaluated each time
306 the interpreter prepares to read a new interactive command; this can
307 be used to implement a dynamic prompt.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000308\end{datadesc}
309
Guido van Rossum9c51e411995-01-10 10:50:58 +0000310\begin{funcdesc}{setcheckinterval}{interval}
311Set the interpreter's ``check interval''. This integer value
312determines how often the interpreter checks for periodic things such
Fred Drake0fd72ee1998-03-08 05:43:51 +0000313as thread switches and signal handlers. The default is \code{10}, meaning
Guido van Rossum9c51e411995-01-10 10:50:58 +0000314the check is performed every 10 Python virtual instructions. Setting
315it to a larger value may increase performance for programs using
Guido van Rossumf259efe1997-11-25 01:00:40 +0000316threads. Setting it to a value \code{<=} 0 checks every virtual instruction,
Guido van Rossum9c51e411995-01-10 10:50:58 +0000317maximizing responsiveness as well as overhead.
Guido van Rossum7f49b7a1995-01-12 12:38:46 +0000318\end{funcdesc}
Guido van Rossum9c51e411995-01-10 10:50:58 +0000319
Fred Drake8940faf2000-10-25 21:02:55 +0000320\begin{funcdesc}{setdefaultencoding}{name}
321 Set the current default string encoding used by the Unicode
322 implementation. If \var{name} does not match any available
323 encoding, \exception{LookupError} is raised. This function is only
324 intended to be used by the \refmodule{site} module implementation
325 and, where needed, by \module{sitecustomize}. Once used by the
326 \refmodule{site} module, it is removed from the \module{sys}
327 module's namespace.
328% Note that \refmodule{site} is not imported if
329% the \programopt{-S} option is passed to the interpreter, in which
330% case this function will remain available.
331 \versionadded{2.0}
332\end{funcdesc}
333
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000334\begin{funcdesc}{setprofile}{profilefunc}
335 Set the system's profile function, which allows you to implement a
Guido van Rossum470be141995-03-17 16:07:09 +0000336 Python source code profiler in Python. See the chapter on the
337 Python Profiler. The system's profile function
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000338 is called similarly to the system's trace function (see
Fred Drake0fd72ee1998-03-08 05:43:51 +0000339 \function{settrace()}), but it isn't called for each executed line of
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000340 code (only on call and return and when an exception occurs). Also,
341 its return value is not used, so it can just return \code{None}.
342\end{funcdesc}
343\index{profile function}
Guido van Rossum470be141995-03-17 16:07:09 +0000344\index{profiler}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000345
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000346\begin{funcdesc}{setrecursionlimit}{limit}
347Set the maximum depth of the Python interpreter stack to \var{limit}.
348This limit prevents infinite recursion from causing an overflow of the
349C stack and crashing Python.
350
351The highest possible limit is platform-dependent. A user may need to
352set the limit higher when she has a program that requires deep
353recursion and a platform that supports a higher limit. This should be
354done with care, because a too-high limit can lead to a crash.
Fred Drake65faf112000-08-31 19:35:56 +0000355\end{funcdesc}
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000356
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000357\begin{funcdesc}{settrace}{tracefunc}
358 Set the system's trace function, which allows you to implement a
359 Python source code debugger in Python. See section ``How It Works''
360 in the chapter on the Python Debugger.
361\end{funcdesc}
362\index{trace function}
363\index{debugger}
364
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000365\begin{datadesc}{stdin}
366\dataline{stdout}
367\dataline{stderr}
368 File objects corresponding to the interpreter's standard input,
Fred Drake0fd72ee1998-03-08 05:43:51 +0000369 output and error streams. \code{stdin} is used for all
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000370 interpreter input except for scripts but including calls to
Fred Drake0fd72ee1998-03-08 05:43:51 +0000371 \function{input()}\bifuncindex{input} and
372 \function{raw_input()}\bifuncindex{raw_input}. \code{stdout} is used
373 for the output of \keyword{print} and expression statements and for the
374 prompts of \function{input()} and \function{raw_input()}. The interpreter's
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000375 own prompts and (almost all of) its error messages go to
Fred Drake0fd72ee1998-03-08 05:43:51 +0000376 \code{stderr}. \code{stdout} and \code{stderr} needn't
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000377 be built-in file objects: any object is acceptable as long as it has
Fred Drake0fd72ee1998-03-08 05:43:51 +0000378 a \method{write()} method that takes a string argument. (Changing these
Guido van Rossum470be141995-03-17 16:07:09 +0000379 objects doesn't affect the standard I/O streams of processes
Fred Drake0fd72ee1998-03-08 05:43:51 +0000380 executed by \function{os.popen()}, \function{os.system()} or the
Fred Drakeffbe6871999-04-22 21:23:22 +0000381 \function{exec*()} family of functions in the \refmodule{os} module.)
Fred Drake54820dc1997-12-15 21:56:05 +0000382\refstmodindex{os}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000383\end{datadesc}
384
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000385\begin{datadesc}{__stdin__}
386\dataline{__stdout__}
387\dataline{__stderr__}
388These objects contain the original values of \code{stdin},
389\code{stderr} and \code{stdout} at the start of the program. They are
390used during finalization, and could be useful to restore the actual
391files to known working file objects in case they have been overwritten
392with a broken object.
393\end{datadesc}
394
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000395\begin{datadesc}{tracebacklimit}
396When this variable is set to an integer value, it determines the
397maximum number of levels of traceback information printed when an
Fred Drake0fd72ee1998-03-08 05:43:51 +0000398unhandled exception occurs. The default is \code{1000}. When set to
3990 or less, all traceback information is suppressed and only the
400exception type and value are printed.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000401\end{datadesc}
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000402
403\begin{datadesc}{version}
Fred Drake38e5d272000-04-03 20:13:55 +0000404A string containing the version number of the Python interpreter plus
405additional information on the build number and compiler used. It has
406a value of the form \code{'\var{version} (\#\var{build_number},
407\var{build_date}, \var{build_time}) [\var{compiler}]'}. The first
408three characters are used to identify the version in the installation
409directories (where appropriate on each platform). An example:
410
411\begin{verbatim}
412>>> import sys
413>>> sys.version
414'1.5.2 (#0 Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)]'
415\end{verbatim}
416\end{datadesc}
417
Fred Drake4d65d732000-04-13 16:54:17 +0000418\begin{datadesc}{version_info}
Fred Drake9cf75872000-04-13 17:51:58 +0000419A tuple containing the five components of the version number:
420\var{major}, \var{minor}, \var{micro}, \var{releaselevel}, and
421\var{serial}. All values except \var{releaselevel} are integers; the
422release level is \code{'alpha'}, \code{'beta'},
423\code{'candidate'}, or \code{'final'}. The \code{version_info} value
Fred Drake30f76ff2000-06-30 16:06:19 +0000424corresponding to the Python version 2.0 is
425\code{(2, 0, 0, 'final', 0)}.
426\versionadded{2.0}
Fred Drake4d65d732000-04-13 16:54:17 +0000427\end{datadesc}
428
Fred Drake38e5d272000-04-03 20:13:55 +0000429\begin{datadesc}{winver}
430The version number used to form registry keys on Windows platforms.
431This is stored as string resource 1000 in the Python DLL. The value
432is normally the first three characters of \constant{version}. It is
433provided in the \module{sys} module for informational purposes;
434modifying this value has no effect on the registry keys used by
435Python.
436Availability: Windows.
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000437\end{datadesc}