blob: 4afef5a30be1fd21dac46a29cee0693b77a10192 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001
2:mod:`sys` --- System-specific parameters and functions
3=======================================================
4
5.. module:: sys
6 :synopsis: Access system-specific parameters and functions.
7
8
9This module provides access to some variables used or maintained by the
10interpreter and to functions that interact strongly with the interpreter. It is
11always available.
12
13
14.. data:: argv
15
16 The list of command line arguments passed to a Python script. ``argv[0]`` is the
17 script name (it is operating system dependent whether this is a full pathname or
18 not). If the command was executed using the :option:`-c` command line option to
19 the interpreter, ``argv[0]`` is set to the string ``'-c'``. If no script name
20 was passed to the Python interpreter, ``argv[0]`` is the empty string.
21
22 To loop over the standard input, or the list of files given on the
23 command line, see the :mod:`fileinput` module.
24
25
26.. data:: byteorder
27
28 An indicator of the native byte order. This will have the value ``'big'`` on
29 big-endian (most-significant byte first) platforms, and ``'little'`` on
30 little-endian (least-significant byte first) platforms.
31
32 .. versionadded:: 2.0
33
34
Georg Brandl8ec7f652007-08-15 14:28:01 +000035.. data:: builtin_module_names
36
37 A tuple of strings giving the names of all modules that are compiled into this
38 Python interpreter. (This information is not available in any other way ---
39 ``modules.keys()`` only lists the imported modules.)
40
41
Georg Brandlb8d0e362010-11-26 07:53:50 +000042.. function:: call_tracing(func, args)
43
44 Call ``func(*args)``, while tracing is enabled. The tracing state is saved,
45 and restored afterwards. This is intended to be called from a debugger from
46 a checkpoint, to recursively debug some other code.
47
48
Georg Brandl8ec7f652007-08-15 14:28:01 +000049.. data:: copyright
50
51 A string containing the copyright pertaining to the Python interpreter.
52
53
Christian Heimes422051a2008-02-04 18:00:12 +000054.. function:: _clear_type_cache()
55
56 Clear the internal type cache. The type cache is used to speed up attribute
57 and method lookups. Use the function *only* to drop unnecessary references
58 during reference leak debugging.
59
60 This function should be used for internal and specialized purposes only.
Christian Heimes908caac2008-01-27 23:34:59 +000061
62 .. versionadded:: 2.6
63
64
Georg Brandl8ec7f652007-08-15 14:28:01 +000065.. function:: _current_frames()
66
67 Return a dictionary mapping each thread's identifier to the topmost stack frame
68 currently active in that thread at the time the function is called. Note that
69 functions in the :mod:`traceback` module can build the call stack given such a
70 frame.
71
72 This is most useful for debugging deadlock: this function does not require the
73 deadlocked threads' cooperation, and such threads' call stacks are frozen for as
74 long as they remain deadlocked. The frame returned for a non-deadlocked thread
75 may bear no relationship to that thread's current activity by the time calling
76 code examines the frame.
77
78 This function should be used for internal and specialized purposes only.
79
80 .. versionadded:: 2.5
81
82
83.. data:: dllhandle
84
85 Integer specifying the handle of the Python DLL. Availability: Windows.
86
87
88.. function:: displayhook(value)
89
90 If *value* is not ``None``, this function prints it to ``sys.stdout``, and saves
91 it in ``__builtin__._``.
92
Georg Brandl584265b2007-12-02 14:58:50 +000093 ``sys.displayhook`` is called on the result of evaluating an :term:`expression`
94 entered in an interactive Python session. The display of these values can be
95 customized by assigning another one-argument function to ``sys.displayhook``.
Georg Brandl8ec7f652007-08-15 14:28:01 +000096
97
98.. function:: excepthook(type, value, traceback)
99
100 This function prints out a given traceback and exception to ``sys.stderr``.
101
102 When an exception is raised and uncaught, the interpreter calls
103 ``sys.excepthook`` with three arguments, the exception class, exception
104 instance, and a traceback object. In an interactive session this happens just
105 before control is returned to the prompt; in a Python program this happens just
106 before the program exits. The handling of such top-level exceptions can be
107 customized by assigning another three-argument function to ``sys.excepthook``.
108
109
110.. data:: __displayhook__
111 __excepthook__
112
113 These objects contain the original values of ``displayhook`` and ``excepthook``
114 at the start of the program. They are saved so that ``displayhook`` and
115 ``excepthook`` can be restored in case they happen to get replaced with broken
116 objects.
117
118
119.. function:: exc_info()
120
121 This function returns a tuple of three values that give information about the
122 exception that is currently being handled. The information returned is specific
123 both to the current thread and to the current stack frame. If the current stack
124 frame is not handling an exception, the information is taken from the calling
125 stack frame, or its caller, and so on until a stack frame is found that is
126 handling an exception. Here, "handling an exception" is defined as "executing
127 or having executed an except clause." For any stack frame, only information
128 about the most recently handled exception is accessible.
129
130 .. index:: object: traceback
131
132 If no exception is being handled anywhere on the stack, a tuple containing three
133 ``None`` values is returned. Otherwise, the values returned are ``(type, value,
134 traceback)``. Their meaning is: *type* gets the exception type of the exception
135 being handled (a class object); *value* gets the exception parameter (its
136 :dfn:`associated value` or the second argument to :keyword:`raise`, which is
137 always a class instance if the exception type is a class object); *traceback*
138 gets a traceback object (see the Reference Manual) which encapsulates the call
139 stack at the point where the exception originally occurred.
140
141 If :func:`exc_clear` is called, this function will return three ``None`` values
142 until either another exception is raised in the current thread or the execution
143 stack returns to a frame where another exception is being handled.
144
145 .. warning::
146
147 Assigning the *traceback* return value to a local variable in a function that is
148 handling an exception will cause a circular reference. This will prevent
149 anything referenced by a local variable in the same function or by the traceback
150 from being garbage collected. Since most functions don't need access to the
151 traceback, the best solution is to use something like ``exctype, value =
152 sys.exc_info()[:2]`` to extract only the exception type and value. If you do
153 need the traceback, make sure to delete it after use (best done with a
154 :keyword:`try` ... :keyword:`finally` statement) or to call :func:`exc_info` in
155 a function that does not itself handle an exception.
156
157 .. note::
158
159 Beginning with Python 2.2, such cycles are automatically reclaimed when garbage
160 collection is enabled and they become unreachable, but it remains more efficient
161 to avoid creating cycles.
162
163
164.. function:: exc_clear()
165
166 This function clears all information relating to the current or last exception
167 that occurred in the current thread. After calling this function,
168 :func:`exc_info` will return three ``None`` values until another exception is
169 raised in the current thread or the execution stack returns to a frame where
170 another exception is being handled.
171
172 This function is only needed in only a few obscure situations. These include
173 logging and error handling systems that report information on the last or
174 current exception. This function can also be used to try to free resources and
175 trigger object finalization, though no guarantee is made as to what objects will
176 be freed, if any.
177
178 .. versionadded:: 2.3
179
180
181.. data:: exc_type
182 exc_value
183 exc_traceback
184
185 .. deprecated:: 1.5
186 Use :func:`exc_info` instead.
187
188 Since they are global variables, they are not specific to the current thread, so
189 their use is not safe in a multi-threaded program. When no exception is being
190 handled, ``exc_type`` is set to ``None`` and the other two are undefined.
191
192
193.. data:: exec_prefix
194
195 A string giving the site-specific directory prefix where the platform-dependent
196 Python files are installed; by default, this is also ``'/usr/local'``. This can
Éric Araujoa8132ec2010-12-16 03:53:53 +0000197 be set at build time with the ``--exec-prefix`` argument to the
Georg Brandl8ec7f652007-08-15 14:28:01 +0000198 :program:`configure` script. Specifically, all configuration files (e.g. the
199 :file:`pyconfig.h` header file) are installed in the directory ``exec_prefix +
200 '/lib/pythonversion/config'``, and shared library modules are installed in
201 ``exec_prefix + '/lib/pythonversion/lib-dynload'``, where *version* is equal to
202 ``version[:3]``.
203
204
205.. data:: executable
206
207 A string giving the name of the executable binary for the Python interpreter, on
208 systems where this makes sense.
209
210
211.. function:: exit([arg])
212
213 Exit from Python. This is implemented by raising the :exc:`SystemExit`
214 exception, so cleanup actions specified by finally clauses of :keyword:`try`
Georg Brandlb8d0e362010-11-26 07:53:50 +0000215 statements are honored, and it is possible to intercept the exit attempt at
216 an outer level.
217
218 The optional argument *arg* can be an integer giving the exit status
219 (defaulting to zero), or another type of object. If it is an integer, zero
220 is considered "successful termination" and any nonzero value is considered
221 "abnormal termination" by shells and the like. Most systems require it to be
222 in the range 0-127, and produce undefined results otherwise. Some systems
223 have a convention for assigning specific meanings to specific exit codes, but
224 these are generally underdeveloped; Unix programs generally use 2 for command
225 line syntax errors and 1 for all other kind of errors. If another type of
226 object is passed, ``None`` is equivalent to passing zero, and any other
227 object is printed to :data:`stderr` and results in an exit code of 1. In
228 particular, ``sys.exit("some error message")`` is a quick way to exit a
229 program when an error occurs.
230
231 Since :func:`exit` ultimately "only" raises an exception, it will only exit
232 the process when called from the main thread, and the exception is not
233 intercepted.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000234
235
236.. data:: exitfunc
237
238 This value is not actually defined by the module, but can be set by the user (or
239 by a program) to specify a clean-up action at program exit. When set, it should
240 be a parameterless function. This function will be called when the interpreter
241 exits. Only one function may be installed in this way; to allow multiple
242 functions which will be called at termination, use the :mod:`atexit` module.
243
244 .. note::
245
246 The exit function is not called when the program is killed by a signal, when a
247 Python fatal internal error is detected, or when ``os._exit()`` is called.
248
249 .. deprecated:: 2.4
250 Use :mod:`atexit` instead.
251
252
Christian Heimesf31b69f2008-01-14 03:42:48 +0000253.. data:: flags
254
255 The struct sequence *flags* exposes the status of command line flags. The
256 attributes are read only.
257
Éric Araujo254d4b82011-03-26 02:09:14 +0100258 ============================= ===================================
259 attribute flag
260 ============================= ===================================
261 :const:`debug` :option:`-d`
262 :const:`py3k_warning` :option:`-3`
263 :const:`division_warning` :option:`-Q`
264 :const:`division_new` :option:`-Qnew <-Q>`
265 :const:`inspect` :option:`-i`
266 :const:`interactive` :option:`-i`
267 :const:`optimize` :option:`-O` or :option:`-OO`
268 :const:`dont_write_bytecode` :option:`-B`
269 :const:`no_user_site` :option:`-s`
270 :const:`no_site` :option:`-S`
271 :const:`ignore_environment` :option:`-E`
272 :const:`tabcheck` :option:`-t` or :option:`-tt <-t>`
273 :const:`verbose` :option:`-v`
274 :const:`unicode` :option:`-U`
275 :const:`bytes_warning` :option:`-b`
276 ============================= ===================================
Christian Heimesf31b69f2008-01-14 03:42:48 +0000277
278 .. versionadded:: 2.6
279
280
Christian Heimesdfdfaab2007-12-01 11:20:10 +0000281.. data:: float_info
282
Christian Heimesc94e2b52008-01-14 04:13:37 +0000283 A structseq holding information about the float type. It contains low level
Mark Dickinson2547ce72010-07-02 18:06:52 +0000284 information about the precision and internal representation. The values
285 correspond to the various floating-point constants defined in the standard
286 header file :file:`float.h` for the 'C' programming language; see section
287 5.2.4.2.2 of the 1999 ISO/IEC C standard [C99]_, 'Characteristics of
288 floating types', for details.
Christian Heimesdfdfaab2007-12-01 11:20:10 +0000289
Mark Dickinson2547ce72010-07-02 18:06:52 +0000290 +---------------------+----------------+--------------------------------------------------+
291 | attribute | float.h macro | explanation |
292 +=====================+================+==================================================+
Mark Dickinson91a63342010-07-03 09:15:09 +0000293 | :const:`epsilon` | DBL_EPSILON | difference between 1 and the least value greater |
Mark Dickinson2547ce72010-07-02 18:06:52 +0000294 | | | than 1 that is representable as a float |
295 +---------------------+----------------+--------------------------------------------------+
296 | :const:`dig` | DBL_DIG | maximum number of decimal digits that can be |
297 | | | faithfully represented in a float; see below |
298 +---------------------+----------------+--------------------------------------------------+
299 | :const:`mant_dig` | DBL_MANT_DIG | float precision: the number of base-``radix`` |
300 | | | digits in the significand of a float |
301 +---------------------+----------------+--------------------------------------------------+
302 | :const:`max` | DBL_MAX | maximum representable finite float |
303 +---------------------+----------------+--------------------------------------------------+
304 | :const:`max_exp` | DBL_MAX_EXP | maximum integer e such that ``radix**(e-1)`` is |
305 | | | a representable finite float |
306 +---------------------+----------------+--------------------------------------------------+
307 | :const:`max_10_exp` | DBL_MAX_10_EXP | maximum integer e such that ``10**e`` is in the |
308 | | | range of representable finite floats |
309 +---------------------+----------------+--------------------------------------------------+
310 | :const:`min` | DBL_MIN | minimum positive normalized float |
311 +---------------------+----------------+--------------------------------------------------+
312 | :const:`min_exp` | DBL_MIN_EXP | minimum integer e such that ``radix**(e-1)`` is |
313 | | | a normalized float |
314 +---------------------+----------------+--------------------------------------------------+
315 | :const:`min_10_exp` | DBL_MIN_10_EXP | minimum integer e such that ``10**e`` is a |
316 | | | normalized float |
317 +---------------------+----------------+--------------------------------------------------+
318 | :const:`radix` | FLT_RADIX | radix of exponent representation |
319 +---------------------+----------------+--------------------------------------------------+
320 | :const:`rounds` | FLT_ROUNDS | constant representing rounding mode |
321 | | | used for arithmetic operations |
322 +---------------------+----------------+--------------------------------------------------+
Christian Heimesdfdfaab2007-12-01 11:20:10 +0000323
Mark Dickinson2547ce72010-07-02 18:06:52 +0000324 The attribute :attr:`sys.float_info.dig` needs further explanation. If
325 ``s`` is any string representing a decimal number with at most
326 :attr:`sys.float_info.dig` significant digits, then converting ``s`` to a
327 float and back again will recover a string representing the same decimal
328 value::
Christian Heimesdfdfaab2007-12-01 11:20:10 +0000329
Mark Dickinson2547ce72010-07-02 18:06:52 +0000330 >>> import sys
331 >>> sys.float_info.dig
332 15
333 >>> s = '3.14159265358979' # decimal string with 15 significant digits
334 >>> format(float(s), '.15g') # convert to float and back -> same value
335 '3.14159265358979'
336
337 But for strings with more than :attr:`sys.float_info.dig` significant digits,
338 this isn't always true::
339
340 >>> s = '9876543211234567' # 16 significant digits is too many!
341 >>> format(float(s), '.16g') # conversion changes value
342 '9876543211234568'
Christian Heimesdfdfaab2007-12-01 11:20:10 +0000343
Christian Heimes3e76d932007-12-01 15:40:22 +0000344 .. versionadded:: 2.6
345
Mark Dickinsonda8652d92009-10-24 14:01:08 +0000346.. data:: float_repr_style
347
348 A string indicating how the :func:`repr` function behaves for
349 floats. If the string has value ``'short'`` then for a finite
350 float ``x``, ``repr(x)`` aims to produce a short string with the
351 property that ``float(repr(x)) == x``. This is the usual behaviour
352 in Python 2.7 and later. Otherwise, ``float_repr_style`` has value
353 ``'legacy'`` and ``repr(x)`` behaves in the same way as it did in
354 versions of Python prior to 2.7.
355
356 .. versionadded:: 2.7
357
Christian Heimesdfdfaab2007-12-01 11:20:10 +0000358
Georg Brandl8ec7f652007-08-15 14:28:01 +0000359.. function:: getcheckinterval()
360
361 Return the interpreter's "check interval"; see :func:`setcheckinterval`.
362
363 .. versionadded:: 2.3
364
365
366.. function:: getdefaultencoding()
367
368 Return the name of the current default string encoding used by the Unicode
369 implementation.
370
371 .. versionadded:: 2.0
372
373
374.. function:: getdlopenflags()
375
376 Return the current value of the flags that are used for :cfunc:`dlopen` calls.
377 The flag constants are defined in the :mod:`dl` and :mod:`DLFCN` modules.
378 Availability: Unix.
379
380 .. versionadded:: 2.2
381
382
383.. function:: getfilesystemencoding()
384
385 Return the name of the encoding used to convert Unicode filenames into system
386 file names, or ``None`` if the system default encoding is used. The result value
387 depends on the operating system:
388
Ezio Melottiab9149d2010-04-29 16:07:20 +0000389 * On Mac OS X, the encoding is ``'utf-8'``.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000390
391 * On Unix, the encoding is the user's preference according to the result of
Ezio Melottiab9149d2010-04-29 16:07:20 +0000392 nl_langinfo(CODESET), or ``None`` if the ``nl_langinfo(CODESET)``
393 failed.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000394
395 * On Windows NT+, file names are Unicode natively, so no conversion is
Ezio Melottiab9149d2010-04-29 16:07:20 +0000396 performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as
397 this is the encoding that applications should use when they explicitly
398 want to convert Unicode strings to byte strings that are equivalent when
399 used as file names.
400
401 * On Windows 9x, the encoding is ``'mbcs'``.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000402
403 .. versionadded:: 2.3
404
405
406.. function:: getrefcount(object)
407
408 Return the reference count of the *object*. The count returned is generally one
409 higher than you might expect, because it includes the (temporary) reference as
410 an argument to :func:`getrefcount`.
411
412
413.. function:: getrecursionlimit()
414
415 Return the current value of the recursion limit, the maximum depth of the Python
416 interpreter stack. This limit prevents infinite recursion from causing an
417 overflow of the C stack and crashing Python. It can be set by
418 :func:`setrecursionlimit`.
419
420
Robert Schuppenies47629022008-07-10 17:13:55 +0000421.. function:: getsizeof(object[, default])
Robert Schuppenies51df0642008-06-01 16:16:17 +0000422
423 Return the size of an object in bytes. The object can be any type of
424 object. All built-in objects will return correct results, but this
Robert Schuppenies47629022008-07-10 17:13:55 +0000425 does not have to hold true for third-party extensions as it is implementation
Robert Schuppenies51df0642008-06-01 16:16:17 +0000426 specific.
427
Benjamin Petersonca66cb52009-09-22 22:15:28 +0000428 If given, *default* will be returned if the object does not provide means to
Georg Brandlf6d367452010-03-12 10:02:03 +0000429 retrieve the size. Otherwise a :exc:`TypeError` will be raised.
Robert Schuppenies47629022008-07-10 17:13:55 +0000430
Benjamin Petersonca66cb52009-09-22 22:15:28 +0000431 :func:`getsizeof` calls the object's ``__sizeof__`` method and adds an
432 additional garbage collector overhead if the object is managed by the garbage
433 collector.
Robert Schuppenies47629022008-07-10 17:13:55 +0000434
Robert Schuppenies51df0642008-06-01 16:16:17 +0000435 .. versionadded:: 2.6
436
437
Georg Brandl8ec7f652007-08-15 14:28:01 +0000438.. function:: _getframe([depth])
439
440 Return a frame object from the call stack. If optional integer *depth* is
441 given, return the frame object that many calls below the top of the stack. If
442 that is deeper than the call stack, :exc:`ValueError` is raised. The default
443 for *depth* is zero, returning the frame at the top of the call stack.
444
Georg Brandl6c14e582009-10-22 11:48:10 +0000445 .. impl-detail::
446
447 This function should be used for internal and specialized purposes only.
448 It is not guaranteed to exist in all implementations of Python.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000449
450
Georg Brandl56112892008-01-20 13:59:46 +0000451.. function:: getprofile()
452
453 .. index::
454 single: profile function
455 single: profiler
456
457 Get the profiler function as set by :func:`setprofile`.
458
459 .. versionadded:: 2.6
460
461
462.. function:: gettrace()
463
464 .. index::
465 single: trace function
466 single: debugger
467
468 Get the trace function as set by :func:`settrace`.
469
Georg Brandl6c14e582009-10-22 11:48:10 +0000470 .. impl-detail::
Georg Brandl56112892008-01-20 13:59:46 +0000471
472 The :func:`gettrace` function is intended only for implementing debuggers,
Georg Brandl6c14e582009-10-22 11:48:10 +0000473 profilers, coverage tools and the like. Its behavior is part of the
474 implementation platform, rather than part of the language definition, and
475 thus may not be available in all Python implementations.
Georg Brandl56112892008-01-20 13:59:46 +0000476
477 .. versionadded:: 2.6
478
479
Georg Brandl8ec7f652007-08-15 14:28:01 +0000480.. function:: getwindowsversion()
481
Eric Smith096d0bf2010-01-27 00:55:16 +0000482 Return a named tuple describing the Windows version
Eric Smithee931b72010-01-27 00:28:29 +0000483 currently running. The named elements are *major*, *minor*,
484 *build*, *platform*, *service_pack*, *service_pack_minor*,
485 *service_pack_major*, *suite_mask*, and *product_type*.
486 *service_pack* contains a string while all other values are
487 integers. The components can also be accessed by name, so
488 ``sys.getwindowsversion()[0]`` is equivalent to
489 ``sys.getwindowsversion().major``. For compatibility with prior
490 versions, only the first 5 elements are retrievable by indexing.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000491
492 *platform* may be one of the following values:
493
Jeroen Ruigrok van der Wervenaa3cadb2008-04-21 20:15:39 +0000494 +-----------------------------------------+-------------------------+
495 | Constant | Platform |
496 +=========================================+=========================+
497 | :const:`0 (VER_PLATFORM_WIN32s)` | Win32s on Windows 3.1 |
498 +-----------------------------------------+-------------------------+
499 | :const:`1 (VER_PLATFORM_WIN32_WINDOWS)` | Windows 95/98/ME |
500 +-----------------------------------------+-------------------------+
501 | :const:`2 (VER_PLATFORM_WIN32_NT)` | Windows NT/2000/XP/x64 |
502 +-----------------------------------------+-------------------------+
503 | :const:`3 (VER_PLATFORM_WIN32_CE)` | Windows CE |
504 +-----------------------------------------+-------------------------+
Georg Brandl8ec7f652007-08-15 14:28:01 +0000505
Eric Smithee931b72010-01-27 00:28:29 +0000506 *product_type* may be one of the following values:
507
508 +---------------------------------------+---------------------------------+
509 | Constant | Meaning |
510 +=======================================+=================================+
511 | :const:`1 (VER_NT_WORKSTATION)` | The system is a workstation. |
512 +---------------------------------------+---------------------------------+
513 | :const:`2 (VER_NT_DOMAIN_CONTROLLER)` | The system is a domain |
514 | | controller. |
515 +---------------------------------------+---------------------------------+
516 | :const:`3 (VER_NT_SERVER)` | The system is a server, but not |
517 | | a domain controller. |
518 +---------------------------------------+---------------------------------+
519
520
521 This function wraps the Win32 :cfunc:`GetVersionEx` function; see the
522 Microsoft documentation on :cfunc:`OSVERSIONINFOEX` for more information
523 about these fields.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000524
525 Availability: Windows.
526
527 .. versionadded:: 2.3
Eric Smithee931b72010-01-27 00:28:29 +0000528 .. versionchanged:: 2.7
529 Changed to a named tuple and added *service_pack_minor*,
530 *service_pack_major*, *suite_mask*, and *product_type*.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000531
532
533.. data:: hexversion
534
535 The version number encoded as a single integer. This is guaranteed to increase
536 with each version, including proper support for non-production releases. For
537 example, to test that the Python interpreter is at least version 1.5.2, use::
538
539 if sys.hexversion >= 0x010502F0:
540 # use some advanced feature
541 ...
542 else:
543 # use an alternative implementation or warn the user
544 ...
545
546 This is called ``hexversion`` since it only really looks meaningful when viewed
547 as the result of passing it to the built-in :func:`hex` function. The
548 ``version_info`` value may be used for a more human-friendly encoding of the
549 same information.
550
R David Murraydcaacbf2011-04-30 16:34:35 -0400551 The ``hexversion`` is a 32-bit number with the following layout:
R David Murraya0895db2011-04-25 16:10:18 -0400552
553 +-------------------------+------------------------------------------------+
R David Murraydcaacbf2011-04-30 16:34:35 -0400554 | Bits (big endian order) | Meaning |
R David Murraya0895db2011-04-25 16:10:18 -0400555 +=========================+================================================+
556 | :const:`1-8` | ``PY_MAJOR_VERSION`` (the ``2`` in |
557 | | ``2.1.0a3``) |
558 +-------------------------+------------------------------------------------+
559 | :const:`9-16` | ``PY_MINOR_VERSION`` (the ``1`` in |
560 | | ``2.1.0a3``) |
561 +-------------------------+------------------------------------------------+
562 | :const:`17-24` | ``PY_MICRO_VERSION`` (the ``0`` in |
563 | | ``2.1.0a3``) |
564 +-------------------------+------------------------------------------------+
565 | :const:`25-28` | ``PY_RELEASE_LEVEL`` (``0xA`` for alpha, |
R David Murraydcaacbf2011-04-30 16:34:35 -0400566 | | ``0xB`` for beta, ``0xC`` for release |
567 | | candidate and ``0xF`` for final) |
R David Murraya0895db2011-04-25 16:10:18 -0400568 +-------------------------+------------------------------------------------+
569 | :const:`29-32` | ``PY_RELEASE_SERIAL`` (the ``3`` in |
R David Murraydcaacbf2011-04-30 16:34:35 -0400570 | | ``2.1.0a3``, zero for final releases) |
R David Murraya0895db2011-04-25 16:10:18 -0400571 +-------------------------+------------------------------------------------+
572
R David Murraydcaacbf2011-04-30 16:34:35 -0400573 Thus ``2.1.0a3`` is hexversion ``0x020100a3``.
R David Murraya0895db2011-04-25 16:10:18 -0400574
Georg Brandl8ec7f652007-08-15 14:28:01 +0000575 .. versionadded:: 1.5.2
576
577
Mark Dickinsonefc82f72009-03-20 15:51:55 +0000578.. data:: long_info
579
580 A struct sequence that holds information about Python's
581 internal representation of integers. The attributes are read only.
582
583 +-------------------------+----------------------------------------------+
R David Murraydcaacbf2011-04-30 16:34:35 -0400584 | Attribute | Explanation |
Mark Dickinsonefc82f72009-03-20 15:51:55 +0000585 +=========================+==============================================+
586 | :const:`bits_per_digit` | number of bits held in each digit. Python |
587 | | integers are stored internally in base |
588 | | ``2**long_info.bits_per_digit`` |
589 +-------------------------+----------------------------------------------+
590 | :const:`sizeof_digit` | size in bytes of the C type used to |
591 | | represent a digit |
592 +-------------------------+----------------------------------------------+
593
594 .. versionadded:: 2.7
595
596
Georg Brandl8ec7f652007-08-15 14:28:01 +0000597.. data:: last_type
598 last_value
599 last_traceback
600
601 These three variables are not always defined; they are set when an exception is
602 not handled and the interpreter prints an error message and a stack traceback.
603 Their intended use is to allow an interactive user to import a debugger module
604 and engage in post-mortem debugging without having to re-execute the command
605 that caused the error. (Typical use is ``import pdb; pdb.pm()`` to enter the
606 post-mortem debugger; see chapter :ref:`debugger` for
607 more information.)
608
609 The meaning of the variables is the same as that of the return values from
610 :func:`exc_info` above. (Since there is only one interactive thread,
611 thread-safety is not a concern for these variables, unlike for ``exc_type``
612 etc.)
613
614
615.. data:: maxint
616
617 The largest positive integer supported by Python's regular integer type. This
618 is at least 2\*\*31-1. The largest negative integer is ``-maxint-1`` --- the
619 asymmetry results from the use of 2's complement binary arithmetic.
620
Martin v. Löwis4dd019f2008-05-20 08:11:19 +0000621.. data:: maxsize
622
623 The largest positive integer supported by the platform's Py_ssize_t type,
624 and thus the maximum size lists, strings, dicts, and many other containers
625 can have.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000626
627.. data:: maxunicode
628
629 An integer giving the largest supported code point for a Unicode character. The
630 value of this depends on the configuration option that specifies whether Unicode
631 characters are stored as UCS-2 or UCS-4.
632
633
Georg Brandl624f3372009-03-31 16:11:45 +0000634.. data:: meta_path
635
636 A list of :term:`finder` objects that have their :meth:`find_module`
637 methods called to see if one of the objects can find the module to be
638 imported. The :meth:`find_module` method is called at least with the
639 absolute name of the module being imported. If the module to be imported is
640 contained in package then the parent package's :attr:`__path__` attribute
641 is passed in as a second argument. The method returns :keyword:`None` if
642 the module cannot be found, else returns a :term:`loader`.
643
644 :data:`sys.meta_path` is searched before any implicit default finders or
645 :data:`sys.path`.
646
647 See :pep:`302` for the original specification.
648
649
Georg Brandl8ec7f652007-08-15 14:28:01 +0000650.. data:: modules
651
652 .. index:: builtin: reload
653
654 This is a dictionary that maps module names to modules which have already been
655 loaded. This can be manipulated to force reloading of modules and other tricks.
656 Note that removing a module from this dictionary is *not* the same as calling
657 :func:`reload` on the corresponding module object.
658
659
660.. data:: path
661
662 .. index:: triple: module; search; path
663
664 A list of strings that specifies the search path for modules. Initialized from
665 the environment variable :envvar:`PYTHONPATH`, plus an installation-dependent
666 default.
667
668 As initialized upon program startup, the first item of this list, ``path[0]``,
669 is the directory containing the script that was used to invoke the Python
670 interpreter. If the script directory is not available (e.g. if the interpreter
671 is invoked interactively or if the script is read from standard input),
672 ``path[0]`` is the empty string, which directs Python to search modules in the
673 current directory first. Notice that the script directory is inserted *before*
674 the entries inserted as a result of :envvar:`PYTHONPATH`.
675
676 A program is free to modify this list for its own purposes.
677
678 .. versionchanged:: 2.3
679 Unicode strings are no longer ignored.
680
Benjamin Peterson4db53b22009-01-10 23:41:59 +0000681 .. seealso::
682 Module :mod:`site` This describes how to use .pth files to extend
683 :data:`sys.path`.
684
Georg Brandl8ec7f652007-08-15 14:28:01 +0000685
Georg Brandl624f3372009-03-31 16:11:45 +0000686.. data:: path_hooks
687
688 A list of callables that take a path argument to try to create a
689 :term:`finder` for the path. If a finder can be created, it is to be
690 returned by the callable, else raise :exc:`ImportError`.
691
692 Originally specified in :pep:`302`.
693
694
695.. data:: path_importer_cache
696
697 A dictionary acting as a cache for :term:`finder` objects. The keys are
698 paths that have been passed to :data:`sys.path_hooks` and the values are
699 the finders that are found. If a path is a valid file system path but no
700 explicit finder is found on :data:`sys.path_hooks` then :keyword:`None` is
701 stored to represent the implicit default finder should be used. If the path
702 is not an existing path then :class:`imp.NullImporter` is set.
703
704 Originally specified in :pep:`302`.
705
706
Georg Brandl8ec7f652007-08-15 14:28:01 +0000707.. data:: platform
708
Georg Brandl440f2ff2008-01-20 12:57:47 +0000709 This string contains a platform identifier that can be used to append
710 platform-specific components to :data:`sys.path`, for instance.
711
Victor Stinnerd99ff292011-09-05 22:33:55 +0200712 For most Unix systems, this is the lowercased OS name as returned by ``uname
713 -s`` with the first part of the version as returned by ``uname -r`` appended,
714 e.g. ``'sunos5'``, *at the time when Python was built*. Unless you want to
715 test for a specific system version, it is therefore recommended to use the
716 following idiom::
Antoine Pitrouea901ad2011-07-09 15:48:29 +0200717
Victor Stinnerd99ff292011-09-05 22:33:55 +0200718 if sys.platform.startswith('freebsd'):
719 # FreeBSD-specific code here...
720 elif sys.platform.startswith('linux'):
Antoine Pitrouea901ad2011-07-09 15:48:29 +0200721 # Linux-specific code here...
722
Victor Stinnerd99ff292011-09-05 22:33:55 +0200723 .. versionchanged:: 2.7.3
724 Since lots of code check for ``sys.platform == 'linux2'``, and there is
725 no essential change between Linux 2.x and 3.x, ``sys.platform`` is always
726 set to ``'linux2'``, even on Linux 3.x. In Python 3.3 and later, the
727 value will always be set to ``'linux'``, so it is recommended to always
728 use the ``startswith`` idiom presented above.
729
Georg Brandl440f2ff2008-01-20 12:57:47 +0000730 For other systems, the values are:
731
Victor Stinnerd99ff292011-09-05 22:33:55 +0200732 ===================== ===========================
733 System :data:`platform` value
734 ===================== ===========================
735 Linux (2.x *and* 3.x) ``'linux2'``
736 Windows ``'win32'``
737 Windows/Cygwin ``'cygwin'``
738 Mac OS X ``'darwin'``
739 OS/2 ``'os2'``
740 OS/2 EMX ``'os2emx'``
741 RiscOS ``'riscos'``
742 AtheOS ``'atheos'``
743 ===================== ===========================
Georg Brandl8ec7f652007-08-15 14:28:01 +0000744
Antoine Pitrouea901ad2011-07-09 15:48:29 +0200745 .. seealso::
746 :attr:`os.name` has a coarser granularity. :func:`os.uname` gives
747 system-dependent version information.
748
749 The :mod:`platform` module provides detailed checks for the
750 system's identity.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000751
752.. data:: prefix
753
754 A string giving the site-specific directory prefix where the platform
755 independent Python files are installed; by default, this is the string
Éric Araujoa8132ec2010-12-16 03:53:53 +0000756 ``'/usr/local'``. This can be set at build time with the ``--prefix``
Georg Brandl8ec7f652007-08-15 14:28:01 +0000757 argument to the :program:`configure` script. The main collection of Python
758 library modules is installed in the directory ``prefix + '/lib/pythonversion'``
759 while the platform independent header files (all except :file:`pyconfig.h`) are
760 stored in ``prefix + '/include/pythonversion'``, where *version* is equal to
761 ``version[:3]``.
762
763
764.. data:: ps1
765 ps2
766
767 .. index::
768 single: interpreter prompts
769 single: prompts, interpreter
770
771 Strings specifying the primary and secondary prompt of the interpreter. These
772 are only defined if the interpreter is in interactive mode. Their initial
773 values in this case are ``'>>> '`` and ``'... '``. If a non-string object is
774 assigned to either variable, its :func:`str` is re-evaluated each time the
775 interpreter prepares to read a new interactive command; this can be used to
776 implement a dynamic prompt.
777
778
Christian Heimesd7b33372007-11-28 08:02:36 +0000779.. data:: py3kwarning
780
781 Bool containing the status of the Python 3.0 warning flag. It's ``True``
Georg Brandl13813f72009-02-26 17:36:26 +0000782 when Python is started with the -3 option. (This should be considered
783 read-only; setting it to a different value doesn't have an effect on
784 Python 3.0 warnings.)
Christian Heimesd7b33372007-11-28 08:02:36 +0000785
Georg Brandl5f794462008-03-21 21:05:03 +0000786 .. versionadded:: 2.6
787
Christian Heimesd7b33372007-11-28 08:02:36 +0000788
Georg Brandl2da0fce2008-01-07 17:09:35 +0000789.. data:: dont_write_bytecode
790
791 If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the
792 import of source modules. This value is initially set to ``True`` or ``False``
793 depending on the ``-B`` command line option and the ``PYTHONDONTWRITEBYTECODE``
794 environment variable, but you can set it yourself to control bytecode file
795 generation.
796
797 .. versionadded:: 2.6
798
799
Georg Brandl8ec7f652007-08-15 14:28:01 +0000800.. function:: setcheckinterval(interval)
801
802 Set the interpreter's "check interval". This integer value determines how often
803 the interpreter checks for periodic things such as thread switches and signal
804 handlers. The default is ``100``, meaning the check is performed every 100
805 Python virtual instructions. Setting it to a larger value may increase
806 performance for programs using threads. Setting it to a value ``<=`` 0 checks
807 every virtual instruction, maximizing responsiveness as well as overhead.
808
809
810.. function:: setdefaultencoding(name)
811
812 Set the current default string encoding used by the Unicode implementation. If
813 *name* does not match any available encoding, :exc:`LookupError` is raised.
814 This function is only intended to be used by the :mod:`site` module
815 implementation and, where needed, by :mod:`sitecustomize`. Once used by the
816 :mod:`site` module, it is removed from the :mod:`sys` module's namespace.
817
Georg Brandlb19be572007-12-29 10:57:00 +0000818 .. Note that :mod:`site` is not imported if the :option:`-S` option is passed
819 to the interpreter, in which case this function will remain available.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000820
821 .. versionadded:: 2.0
822
823
824.. function:: setdlopenflags(n)
825
826 Set the flags used by the interpreter for :cfunc:`dlopen` calls, such as when
827 the interpreter loads extension modules. Among other things, this will enable a
828 lazy resolving of symbols when importing a module, if called as
829 ``sys.setdlopenflags(0)``. To share symbols across extension modules, call as
830 ``sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL)``. Symbolic names for the
831 flag modules can be either found in the :mod:`dl` module, or in the :mod:`DLFCN`
832 module. If :mod:`DLFCN` is not available, it can be generated from
833 :file:`/usr/include/dlfcn.h` using the :program:`h2py` script. Availability:
834 Unix.
835
836 .. versionadded:: 2.2
837
838
839.. function:: setprofile(profilefunc)
840
841 .. index::
842 single: profile function
843 single: profiler
844
845 Set the system's profile function, which allows you to implement a Python source
846 code profiler in Python. See chapter :ref:`profile` for more information on the
847 Python profiler. The system's profile function is called similarly to the
848 system's trace function (see :func:`settrace`), but it isn't called for each
849 executed line of code (only on call and return, but the return event is reported
850 even when an exception has been set). The function is thread-specific, but
851 there is no way for the profiler to know about context switches between threads,
852 so it does not make sense to use this in the presence of multiple threads. Also,
853 its return value is not used, so it can simply return ``None``.
854
855
856.. function:: setrecursionlimit(limit)
857
858 Set the maximum depth of the Python interpreter stack to *limit*. This limit
859 prevents infinite recursion from causing an overflow of the C stack and crashing
860 Python.
861
862 The highest possible limit is platform-dependent. A user may need to set the
863 limit higher when she has a program that requires deep recursion and a platform
864 that supports a higher limit. This should be done with care, because a too-high
865 limit can lead to a crash.
866
867
868.. function:: settrace(tracefunc)
869
870 .. index::
871 single: trace function
872 single: debugger
873
874 Set the system's trace function, which allows you to implement a Python
Benjamin Peterson050f4ad2008-11-20 21:25:31 +0000875 source code debugger in Python. The function is thread-specific; for a
Georg Brandl8ec7f652007-08-15 14:28:01 +0000876 debugger to support multiple threads, it must be registered using
877 :func:`settrace` for each thread being debugged.
878
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000879 Trace functions should have three arguments: *frame*, *event*, and
880 *arg*. *frame* is the current stack frame. *event* is a string: ``'call'``,
881 ``'line'``, ``'return'``, ``'exception'``, ``'c_call'``, ``'c_return'``, or
882 ``'c_exception'``. *arg* depends on the event type.
883
884 The trace function is invoked (with *event* set to ``'call'``) whenever a new
885 local scope is entered; it should return a reference to a local trace
886 function to be used that scope, or ``None`` if the scope shouldn't be traced.
887
888 The local trace function should return a reference to itself (or to another
889 function for further tracing in that scope), or ``None`` to turn off tracing
890 in that scope.
891
892 The events have the following meaning:
893
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000894 ``'call'``
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000895 A function is called (or some other code block entered). The
896 global trace function is called; *arg* is ``None``; the return value
897 specifies the local trace function.
898
899 ``'line'``
Jeffrey Yasskin655d8352009-05-23 23:23:01 +0000900 The interpreter is about to execute a new line of code or re-execute the
901 condition of a loop. The local trace function is called; *arg* is
902 ``None``; the return value specifies the new local trace function. See
903 :file:`Objects/lnotab_notes.txt` for a detailed explanation of how this
904 works.
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000905
906 ``'return'``
907 A function (or other code block) is about to return. The local trace
Georg Brandl78f11ed2010-11-26 07:34:20 +0000908 function is called; *arg* is the value that will be returned, or ``None``
909 if the event is caused by an exception being raised. The trace function's
910 return value is ignored.
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000911
912 ``'exception'``
913 An exception has occurred. The local trace function is called; *arg* is a
914 tuple ``(exception, value, traceback)``; the return value specifies the
915 new local trace function.
916
917 ``'c_call'``
918 A C function is about to be called. This may be an extension function or
Georg Brandld7d4fd72009-07-26 14:37:28 +0000919 a built-in. *arg* is the C function object.
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000920
921 ``'c_return'``
Georg Brandl78f11ed2010-11-26 07:34:20 +0000922 A C function has returned. *arg* is the C function object.
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000923
924 ``'c_exception'``
Georg Brandl78f11ed2010-11-26 07:34:20 +0000925 A C function has raised an exception. *arg* is the C function object.
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000926
Benjamin Peterson050f4ad2008-11-20 21:25:31 +0000927 Note that as an exception is propagated down the chain of callers, an
928 ``'exception'`` event is generated at each level.
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000929
Benjamin Peterson050f4ad2008-11-20 21:25:31 +0000930 For more information on code and frame objects, refer to :ref:`types`.
Benjamin Peterson5ab9c3b2008-11-20 04:05:12 +0000931
Georg Brandl6c14e582009-10-22 11:48:10 +0000932 .. impl-detail::
Georg Brandl8ec7f652007-08-15 14:28:01 +0000933
934 The :func:`settrace` function is intended only for implementing debuggers,
Georg Brandl6c14e582009-10-22 11:48:10 +0000935 profilers, coverage tools and the like. Its behavior is part of the
936 implementation platform, rather than part of the language definition, and
937 thus may not be available in all Python implementations.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000938
939
940.. function:: settscdump(on_flag)
941
942 Activate dumping of VM measurements using the Pentium timestamp counter, if
943 *on_flag* is true. Deactivate these dumps if *on_flag* is off. The function is
Éric Araujoa8132ec2010-12-16 03:53:53 +0000944 available only if Python was compiled with ``--with-tsc``. To understand
Georg Brandl8ec7f652007-08-15 14:28:01 +0000945 the output of this dump, read :file:`Python/ceval.c` in the Python sources.
946
947 .. versionadded:: 2.4
948
Benjamin Petersona7fa0322010-03-06 03:13:33 +0000949 .. impl-detail::
950
951 This function is intimately bound to CPython implementation details and
952 thus not likely to be implemented elsewhere.
953
Georg Brandl8ec7f652007-08-15 14:28:01 +0000954
955.. data:: stdin
956 stdout
957 stderr
958
959 .. index::
960 builtin: input
961 builtin: raw_input
962
963 File objects corresponding to the interpreter's standard input, output and error
964 streams. ``stdin`` is used for all interpreter input except for scripts but
965 including calls to :func:`input` and :func:`raw_input`. ``stdout`` is used for
Georg Brandl584265b2007-12-02 14:58:50 +0000966 the output of :keyword:`print` and :term:`expression` statements and for the
967 prompts of :func:`input` and :func:`raw_input`. The interpreter's own prompts
968 and (almost all of) its error messages go to ``stderr``. ``stdout`` and
969 ``stderr`` needn't be built-in file objects: any object is acceptable as long
Georg Brandlc62ef8b2009-01-03 20:55:06 +0000970 as it has a :meth:`write` method that takes a string argument. (Changing these
Georg Brandl584265b2007-12-02 14:58:50 +0000971 objects doesn't affect the standard I/O streams of processes executed by
Georg Brandl8ec7f652007-08-15 14:28:01 +0000972 :func:`os.popen`, :func:`os.system` or the :func:`exec\*` family of functions in
973 the :mod:`os` module.)
974
975
976.. data:: __stdin__
977 __stdout__
978 __stderr__
979
980 These objects contain the original values of ``stdin``, ``stderr`` and
Georg Brandlb48adec2009-03-31 19:10:35 +0000981 ``stdout`` at the start of the program. They are used during finalization,
982 and could be useful to print to the actual standard stream no matter if the
983 ``sys.std*`` object has been redirected.
984
985 It can also be used to restore the actual files to known working file objects
986 in case they have been overwritten with a broken object. However, the
987 preferred way to do this is to explicitly save the previous stream before
988 replacing it, and restore the saved object.
Georg Brandl8ec7f652007-08-15 14:28:01 +0000989
990
Antoine Pitrou73705902011-07-09 16:06:19 +0200991.. data:: subversion
992
993 A triple (repo, branch, version) representing the Subversion information of the
994 Python interpreter. *repo* is the name of the repository, ``'CPython'``.
995 *branch* is a string of one of the forms ``'trunk'``, ``'branches/name'`` or
996 ``'tags/name'``. *version* is the output of ``svnversion``, if the interpreter
997 was built from a Subversion checkout; it contains the revision number (range)
998 and possibly a trailing 'M' if there were local modifications. If the tree was
999 exported (or svnversion was not available), it is the revision of
1000 ``Include/patchlevel.h`` if the branch is a tag. Otherwise, it is ``None``.
1001
1002 .. versionadded:: 2.5
1003
1004 .. note::
1005 Python is now `developed <http://docs.python.org/devguide/>`_ using
1006 Mercurial. In recent Python 2.7 bugfix releases, :data:`subversion`
1007 therefore contains placeholder information. It is removed in Python
1008 3.3.
1009
1010
Georg Brandl8ec7f652007-08-15 14:28:01 +00001011.. data:: tracebacklimit
1012
1013 When this variable is set to an integer value, it determines the maximum number
1014 of levels of traceback information printed when an unhandled exception occurs.
1015 The default is ``1000``. When set to ``0`` or less, all traceback information
1016 is suppressed and only the exception type and value are printed.
1017
1018
1019.. data:: version
1020
1021 A string containing the version number of the Python interpreter plus additional
Georg Brandle2773252010-08-01 19:14:56 +00001022 information on the build number and compiler used. This string is displayed
1023 when the interactive interpreter is started. Do not extract version information
1024 out of it, rather, use :data:`version_info` and the functions provided by the
1025 :mod:`platform` module.
Georg Brandl8ec7f652007-08-15 14:28:01 +00001026
1027
1028.. data:: api_version
1029
1030 The C API version for this interpreter. Programmers may find this useful when
1031 debugging version conflicts between Python and extension modules.
1032
1033 .. versionadded:: 2.3
1034
1035
1036.. data:: version_info
1037
1038 A tuple containing the five components of the version number: *major*, *minor*,
1039 *micro*, *releaselevel*, and *serial*. All values except *releaselevel* are
1040 integers; the release level is ``'alpha'``, ``'beta'``, ``'candidate'``, or
1041 ``'final'``. The ``version_info`` value corresponding to the Python version 2.0
Eric Smith81fe0932009-02-06 00:48:26 +00001042 is ``(2, 0, 0, 'final', 0)``. The components can also be accessed by name,
1043 so ``sys.version_info[0]`` is equivalent to ``sys.version_info.major``
1044 and so on.
Georg Brandl8ec7f652007-08-15 14:28:01 +00001045
1046 .. versionadded:: 2.0
Eric Smith81fe0932009-02-06 00:48:26 +00001047 .. versionchanged:: 2.7
1048 Added named component attributes
Georg Brandl8ec7f652007-08-15 14:28:01 +00001049
1050
1051.. data:: warnoptions
1052
1053 This is an implementation detail of the warnings framework; do not modify this
1054 value. Refer to the :mod:`warnings` module for more information on the warnings
1055 framework.
1056
1057
1058.. data:: winver
1059
1060 The version number used to form registry keys on Windows platforms. This is
1061 stored as string resource 1000 in the Python DLL. The value is normally the
1062 first three characters of :const:`version`. It is provided in the :mod:`sys`
1063 module for informational purposes; modifying this value has no effect on the
1064 registry keys used by Python. Availability: Windows.
Mark Dickinson2547ce72010-07-02 18:06:52 +00001065
1066.. rubric:: Citations
1067
1068.. [C99] ISO/IEC 9899:1999. "Programming languages -- C." A public draft of this standard is available at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf .
1069