blob: df32182e666b7f3e7acd3f201bb4ca360e69d1b2 [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
51This function is called when an expression is entered at the prompt
52of an interactive Python session. It exists mainly so it can be
53overridden.
54\end{funcdesc}
55
Guido van Rossum871cf161997-10-20 22:38:43 +000056\begin{funcdesc}{exc_info}{}
57This function returns a tuple of three values that give information
58about the exception that is currently being handled. The information
59returned is specific both to the current thread and to the current
60stack frame. If the current stack frame is not handling an exception,
61the information is taken from the calling stack frame, or its caller,
62and so on until a stack frame is found that is handling an exception.
63Here, ``handling an exception'' is defined as ``executing or having
Fred Drake0fd72ee1998-03-08 05:43:51 +000064executed an except clause.'' For any stack frame, only
Guido van Rossum871cf161997-10-20 22:38:43 +000065information about the most recently handled exception is accessible.
66
67If no exception is being handled anywhere on the stack, a tuple
68containing three \code{None} values is returned. Otherwise, the
69values returned are
70\code{(\var{type}, \var{value}, \var{traceback})}.
71Their meaning is: \var{type} gets the exception type of the exception
72being handled (a string or class object); \var{value} gets the
73exception parameter (its \dfn{associated value} or the second argument
Fred Drake0fd72ee1998-03-08 05:43:51 +000074to \keyword{raise}, which is always a class instance if the exception
Guido van Rossum871cf161997-10-20 22:38:43 +000075type is a class object); \var{traceback} gets a traceback object (see
76the Reference Manual) which encapsulates the call stack at the point
77where the exception originally occurred.
78\obindex{traceback}
79
80\strong{Warning:} assigning the \var{traceback} return value to a
81local variable in a function that is handling an exception will cause
82a circular reference. This will prevent anything referenced by a local
83variable in the same function or by the traceback from being garbage
84collected. Since most functions don't need access to the traceback,
85the best solution is to use something like
86\code{type, value = sys.exc_info()[:2]}
87to extract only the exception type and value. If you do need the
88traceback, make sure to delete it after use (best done with a
Fred Drake0fd72ee1998-03-08 05:43:51 +000089\keyword{try} ... \keyword{finally} statement) or to call
90\function{exc_info()} in a function that does not itself handle an
91exception.
Guido van Rossum871cf161997-10-20 22:38:43 +000092\end{funcdesc}
93
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000094\begin{datadesc}{exc_type}
95\dataline{exc_value}
96\dataline{exc_traceback}
Fred Drake0fd72ee1998-03-08 05:43:51 +000097\deprecated {1.5}
98 {Use \function{exc_info()} instead.}
99Since they are global variables, they are not specific to the current
Guido van Rossum871cf161997-10-20 22:38:43 +0000100thread, so their use is not safe in a multi-threaded program. When no
Fred Drake0fd72ee1998-03-08 05:43:51 +0000101exception is being handled, \code{exc_type} is set to \code{None} and
102the other two are undefined.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000103\end{datadesc}
104
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000105\begin{datadesc}{exec_prefix}
Fred Drake268df271999-11-09 19:45:59 +0000106A string giving the site-specific directory prefix where the
107platform-dependent Python files are installed; by default, this is
108also \code{'/usr/local'}. This can be set at build time with the
Fred Drakeee775a12000-04-11 19:46:40 +0000109\longprogramopt{exec-prefix} argument to the
Fred Drake0fd72ee1998-03-08 05:43:51 +0000110\program{configure} script. Specifically, all configuration files
111(e.g. the \file{config.h} header file) are installed in the directory
Fred Drake268df271999-11-09 19:45:59 +0000112\code{exec_prefix + '/lib/python\var{version}/config'}, and shared
113library modules are installed in \code{exec_prefix +
114'/lib/python\var{version}/lib-dynload'}, where \var{version} is equal
115to \code{version[:3]}.
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000116\end{datadesc}
117
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000118\begin{datadesc}{executable}
119A string giving the name of the executable binary for the Python
120interpreter, on systems where this makes sense.
121\end{datadesc}
122
Guido van Rossum04307ce1998-11-23 17:49:53 +0000123\begin{funcdesc}{exit}{\optional{arg}}
124Exit from Python. This is implemented by raising the
125\exception{SystemExit} exception, so cleanup actions specified by
126finally clauses of \keyword{try} statements are honored, and it is
127possible to intercept the exit attempt at an outer level. The
128optional argument \var{arg} can be an integer giving the exit status
129(defaulting to zero), or another type of object. If it is an integer,
130zero is considered ``successful termination'' and any nonzero value is
131considered ``abnormal termination'' by shells and the like. Most
132systems require it to be in the range 0-127, and produce undefined
133results otherwise. Some systems have a convention for assigning
134specific meanings to specific exit codes, but these are generally
135underdeveloped; Unix programs generally use 2 for command line syntax
136errors and 1 for all other kind of errors. If another type of object
137is passed, \code{None} is equivalent to passing zero, and any other
138object is printed to \code{sys.stderr} and results in an exit code of
1391. In particular, \code{sys.exit("some error message")} is a quick
140way to exit a program when an error occurs.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000141\end{funcdesc}
142
143\begin{datadesc}{exitfunc}
144 This value is not actually defined by the module, but can be set by
145 the user (or by a program) to specify a clean-up action at program
146 exit. When set, it should be a parameterless function. This function
Fred Drakec19425d2000-06-28 15:07:31 +0000147 will be called when the interpreter exits. Only one function may be
148 installed in this way; to allow multiple functions which will be called
149 at termination, use the \refmodule{atexit} module. Note: the exit function
Guido van Rossum5fc9c861999-03-25 20:30:00 +0000150 is not called when the program is killed by a signal, when a Python
151 fatal internal error is detected, or when \code{os._exit()} is called.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000152\end{datadesc}
153
Fred Drake8940faf2000-10-25 21:02:55 +0000154\begin{funcdesc}{getdefaultencoding}{}
155 Return the name of the current default string encoding used by the
156 Unicode implementation.
157 \versionadded{2.0}
158\end{funcdesc}
159
Guido van Rossum6e91c6a1998-02-07 21:17:05 +0000160\begin{funcdesc}{getrefcount}{object}
161Return the reference count of the \var{object}. The count returned is
162generally one higher than you might expect, because it includes the
Fred Drakeb91e9341998-07-23 17:59:49 +0000163(temporary) reference as an argument to \function{getrefcount()}.
Guido van Rossum6e91c6a1998-02-07 21:17:05 +0000164\end{funcdesc}
165
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000166\begin{funcdesc}{getrecursionlimit}{}
167Return the current value of the recursion limit, the maximum depth of
168the Python interpreter stack. This limit prevents infinite recursion
169from causing an overflow of the C stack and crashing Python. It can
Fred Drake65faf112000-08-31 19:35:56 +0000170be set by \function{setrecursionlimit()}.
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000171\end{funcdesc}
172
Barry Warsawb6a54d22000-12-06 21:47:46 +0000173\begin{funcdesc}{_getframe}{\optional{depth}}
174Return a frame object from the call stack. If optional integer
175\var{depth} is given, return the frame object that many calls below
176the top of the stack. If that is deeper than the call stack,
177\exception{ValueError} is raised. The default for \var{depth} is
178zero, returning the frame at the top of the call stack.
179
180This function should be used for internal and specialized
181purposes only.
182\end{funcdesc}
183
Fred Drake4d65d732000-04-13 16:54:17 +0000184\begin{datadesc}{hexversion}
185The version number encoded as a single integer. This is guaranteed to
186increase with each version, including proper support for
187non-production releases. For example, to test that the Python
188interpreter is at least version 1.5.2, use:
189
190\begin{verbatim}
191if sys.hexversion >= 0x010502F0:
192 # use some advanced feature
193 ...
194else:
195 # use an alternative implementation or warn the user
196 ...
197\end{verbatim}
198
199This is called \samp{hexversion} since it only really looks meaningful
200when viewed as the result of passing it to the built-in
201\function{hex()} function. The \code{version_info} value may be used
202for a more human-friendly encoding of the same information.
203\versionadded{1.5.2}
204\end{datadesc}
205
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000206\begin{datadesc}{last_type}
207\dataline{last_value}
208\dataline{last_traceback}
Guido van Rossum871cf161997-10-20 22:38:43 +0000209These three variables are not always defined; they are set when an
210exception is not handled and the interpreter prints an error message
211and a stack traceback. Their intended use is to allow an interactive
212user to import a debugger module and engage in post-mortem debugging
213without having to re-execute the command that caused the error.
Fred Drake0fd72ee1998-03-08 05:43:51 +0000214(Typical use is \samp{import pdb; pdb.pm()} to enter the post-mortem
Guido van Rossum871cf161997-10-20 22:38:43 +0000215debugger; see the chapter ``The Python Debugger'' for more
216information.)
Fred Drake54820dc1997-12-15 21:56:05 +0000217\refstmodindex{pdb}
Guido van Rossum871cf161997-10-20 22:38:43 +0000218
219The meaning of the variables is the same
Fred Drake0fd72ee1998-03-08 05:43:51 +0000220as that of the return values from \function{exc_info()} above.
Guido van Rossum871cf161997-10-20 22:38:43 +0000221(Since there is only one interactive thread, thread-safety is not a
Fred Drake0fd72ee1998-03-08 05:43:51 +0000222concern for these variables, unlike for \code{exc_type} etc.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000223\end{datadesc}
224
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000225\begin{datadesc}{maxint}
226The largest positive integer supported by Python's regular integer
227type. This is at least 2**31-1. The largest negative integer is
228\code{-maxint-1} -- the asymmetry results from the use of 2's
229complement binary arithmetic.
230\end{datadesc}
231
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000232\begin{datadesc}{modules}
Fred Drake0fd72ee1998-03-08 05:43:51 +0000233 This is a dictionary that maps module names to modules which have
234 already been loaded. This can be manipulated to force reloading of
235 modules and other tricks. Note that removing a module from this
236 dictionary is \emph{not} the same as calling
237 \function{reload()}\bifuncindex{reload} on the corresponding module
238 object.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000239\end{datadesc}
240
241\begin{datadesc}{path}
Fred Drake2b67bee1998-01-13 18:35:51 +0000242\indexiii{module}{search}{path}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000243 A list of strings that specifies the search path for modules.
Fred Drakeb91e9341998-07-23 17:59:49 +0000244 Initialized from the environment variable \envvar{PYTHONPATH}, or an
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000245 installation-dependent default.
246
Fred Drake0fd72ee1998-03-08 05:43:51 +0000247The first item of this list, \code{path[0]}, is the
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000248directory containing the script that was used to invoke the Python
249interpreter. If the script directory is not available (e.g. if the
250interpreter is invoked interactively or if the script is read from
Fred Drake0fd72ee1998-03-08 05:43:51 +0000251standard input), \code{path[0]} is the empty string, which directs
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000252Python to search modules in the current directory first. Notice that
Fred Drake54820dc1997-12-15 21:56:05 +0000253the script directory is inserted \emph{before} the entries inserted as
Fred Drakeb91e9341998-07-23 17:59:49 +0000254a result of \envvar{PYTHONPATH}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000255\end{datadesc}
256
Guido van Rossum6b686e91995-07-07 23:00:35 +0000257\begin{datadesc}{platform}
Fred Drake0fd72ee1998-03-08 05:43:51 +0000258This string contains a platform identifier, e.g. \code{'sunos5'} or
259\code{'linux1'}. This can be used to append platform-specific
260components to \code{path}, for instance.
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000261\end{datadesc}
262
263\begin{datadesc}{prefix}
264A string giving the site-specific directory prefix where the platform
265independent Python files are installed; by default, this is the string
Fred Drakeb91e9341998-07-23 17:59:49 +0000266\code{'/usr/local'}. This can be set at build time with the
Fred Drakeee775a12000-04-11 19:46:40 +0000267\longprogramopt{prefix} argument to the
Fred Drake268df271999-11-09 19:45:59 +0000268\program{configure} script. The main collection of Python library
269modules is installed in the directory \code{prefix +
270'/lib/python\var{version}'} while the platform independent header
271files (all except \file{config.h}) are stored in \code{prefix +
272'/include/python\var{version}'}, where \var{version} is equal to
273\code{version[:3]}.
Guido van Rossum6b686e91995-07-07 23:00:35 +0000274\end{datadesc}
275
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000276\begin{datadesc}{ps1}
277\dataline{ps2}
Fred Drakee6cedb31998-04-03 07:05:16 +0000278\index{interpreter prompts}
279\index{prompts, interpreter}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000280 Strings specifying the primary and secondary prompt of the
281 interpreter. These are only defined if the interpreter is in
282 interactive mode. Their initial values in this case are
Fred Drake8940faf2000-10-25 21:02:55 +0000283 \code{'>\code{>}> '} and \code{'... '}. If a non-string object is assigned
Fred Drake0fd72ee1998-03-08 05:43:51 +0000284 to either variable, its \function{str()} is re-evaluated each time
285 the interpreter prepares to read a new interactive command; this can
286 be used to implement a dynamic prompt.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000287\end{datadesc}
288
Guido van Rossum9c51e411995-01-10 10:50:58 +0000289\begin{funcdesc}{setcheckinterval}{interval}
290Set the interpreter's ``check interval''. This integer value
291determines how often the interpreter checks for periodic things such
Fred Drake0fd72ee1998-03-08 05:43:51 +0000292as thread switches and signal handlers. The default is \code{10}, meaning
Guido van Rossum9c51e411995-01-10 10:50:58 +0000293the check is performed every 10 Python virtual instructions. Setting
294it to a larger value may increase performance for programs using
Guido van Rossumf259efe1997-11-25 01:00:40 +0000295threads. Setting it to a value \code{<=} 0 checks every virtual instruction,
Guido van Rossum9c51e411995-01-10 10:50:58 +0000296maximizing responsiveness as well as overhead.
Guido van Rossum7f49b7a1995-01-12 12:38:46 +0000297\end{funcdesc}
Guido van Rossum9c51e411995-01-10 10:50:58 +0000298
Fred Drake8940faf2000-10-25 21:02:55 +0000299\begin{funcdesc}{setdefaultencoding}{name}
300 Set the current default string encoding used by the Unicode
301 implementation. If \var{name} does not match any available
302 encoding, \exception{LookupError} is raised. This function is only
303 intended to be used by the \refmodule{site} module implementation
304 and, where needed, by \module{sitecustomize}. Once used by the
305 \refmodule{site} module, it is removed from the \module{sys}
306 module's namespace.
307% Note that \refmodule{site} is not imported if
308% the \programopt{-S} option is passed to the interpreter, in which
309% case this function will remain available.
310 \versionadded{2.0}
311\end{funcdesc}
312
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000313\begin{funcdesc}{setprofile}{profilefunc}
314 Set the system's profile function, which allows you to implement a
Guido van Rossum470be141995-03-17 16:07:09 +0000315 Python source code profiler in Python. See the chapter on the
316 Python Profiler. The system's profile function
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000317 is called similarly to the system's trace function (see
Fred Drake0fd72ee1998-03-08 05:43:51 +0000318 \function{settrace()}), but it isn't called for each executed line of
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000319 code (only on call and return and when an exception occurs). Also,
320 its return value is not used, so it can just return \code{None}.
321\end{funcdesc}
322\index{profile function}
Guido van Rossum470be141995-03-17 16:07:09 +0000323\index{profiler}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000324
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000325\begin{funcdesc}{setrecursionlimit}{limit}
326Set the maximum depth of the Python interpreter stack to \var{limit}.
327This limit prevents infinite recursion from causing an overflow of the
328C stack and crashing Python.
329
330The highest possible limit is platform-dependent. A user may need to
331set the limit higher when she has a program that requires deep
332recursion and a platform that supports a higher limit. This should be
333done with care, because a too-high limit can lead to a crash.
Fred Drake65faf112000-08-31 19:35:56 +0000334\end{funcdesc}
Jeremy Hyltonee5adfb2000-08-31 19:23:01 +0000335
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000336\begin{funcdesc}{settrace}{tracefunc}
337 Set the system's trace function, which allows you to implement a
338 Python source code debugger in Python. See section ``How It Works''
339 in the chapter on the Python Debugger.
340\end{funcdesc}
341\index{trace function}
342\index{debugger}
343
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000344\begin{datadesc}{stdin}
345\dataline{stdout}
346\dataline{stderr}
347 File objects corresponding to the interpreter's standard input,
Fred Drake0fd72ee1998-03-08 05:43:51 +0000348 output and error streams. \code{stdin} is used for all
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000349 interpreter input except for scripts but including calls to
Fred Drake0fd72ee1998-03-08 05:43:51 +0000350 \function{input()}\bifuncindex{input} and
351 \function{raw_input()}\bifuncindex{raw_input}. \code{stdout} is used
352 for the output of \keyword{print} and expression statements and for the
353 prompts of \function{input()} and \function{raw_input()}. The interpreter's
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000354 own prompts and (almost all of) its error messages go to
Fred Drake0fd72ee1998-03-08 05:43:51 +0000355 \code{stderr}. \code{stdout} and \code{stderr} needn't
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000356 be built-in file objects: any object is acceptable as long as it has
Fred Drake0fd72ee1998-03-08 05:43:51 +0000357 a \method{write()} method that takes a string argument. (Changing these
Guido van Rossum470be141995-03-17 16:07:09 +0000358 objects doesn't affect the standard I/O streams of processes
Fred Drake0fd72ee1998-03-08 05:43:51 +0000359 executed by \function{os.popen()}, \function{os.system()} or the
Fred Drakeffbe6871999-04-22 21:23:22 +0000360 \function{exec*()} family of functions in the \refmodule{os} module.)
Fred Drake54820dc1997-12-15 21:56:05 +0000361\refstmodindex{os}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000362\end{datadesc}
363
Guido van Rossum3e5fe421998-06-10 17:57:44 +0000364\begin{datadesc}{__stdin__}
365\dataline{__stdout__}
366\dataline{__stderr__}
367These objects contain the original values of \code{stdin},
368\code{stderr} and \code{stdout} at the start of the program. They are
369used during finalization, and could be useful to restore the actual
370files to known working file objects in case they have been overwritten
371with a broken object.
372\end{datadesc}
373
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000374\begin{datadesc}{tracebacklimit}
375When this variable is set to an integer value, it determines the
376maximum number of levels of traceback information printed when an
Fred Drake0fd72ee1998-03-08 05:43:51 +0000377unhandled exception occurs. The default is \code{1000}. When set to
3780 or less, all traceback information is suppressed and only the
379exception type and value are printed.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000380\end{datadesc}
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000381
382\begin{datadesc}{version}
Fred Drake38e5d272000-04-03 20:13:55 +0000383A string containing the version number of the Python interpreter plus
384additional information on the build number and compiler used. It has
385a value of the form \code{'\var{version} (\#\var{build_number},
386\var{build_date}, \var{build_time}) [\var{compiler}]'}. The first
387three characters are used to identify the version in the installation
388directories (where appropriate on each platform). An example:
389
390\begin{verbatim}
391>>> import sys
392>>> sys.version
393'1.5.2 (#0 Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)]'
394\end{verbatim}
395\end{datadesc}
396
Fred Drake4d65d732000-04-13 16:54:17 +0000397\begin{datadesc}{version_info}
Fred Drake9cf75872000-04-13 17:51:58 +0000398A tuple containing the five components of the version number:
399\var{major}, \var{minor}, \var{micro}, \var{releaselevel}, and
400\var{serial}. All values except \var{releaselevel} are integers; the
401release level is \code{'alpha'}, \code{'beta'},
402\code{'candidate'}, or \code{'final'}. The \code{version_info} value
Fred Drake30f76ff2000-06-30 16:06:19 +0000403corresponding to the Python version 2.0 is
404\code{(2, 0, 0, 'final', 0)}.
405\versionadded{2.0}
Fred Drake4d65d732000-04-13 16:54:17 +0000406\end{datadesc}
407
Fred Drake38e5d272000-04-03 20:13:55 +0000408\begin{datadesc}{winver}
409The version number used to form registry keys on Windows platforms.
410This is stored as string resource 1000 in the Python DLL. The value
411is normally the first three characters of \constant{version}. It is
412provided in the \module{sys} module for informational purposes;
413modifying this value has no effect on the registry keys used by
414Python.
415Availability: Windows.
Guido van Rossum0a3c7531997-06-02 17:32:41 +0000416\end{datadesc}