annotate Doc/library/sys.rst @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 8aab13719c02
children 2303165434b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1 :mod:`sys` --- System-specific parameters and functions
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
2 =======================================================
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
3
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
4 .. module:: sys
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
5 :synopsis: Access system-specific parameters and functions.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
6
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
7
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
8 This module provides access to some variables used or maintained by the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
9 interpreter and to functions that interact strongly with the interpreter. It is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
10 always available.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
11
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
12
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
13 .. data:: argv
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
14
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
15 The list of command line arguments passed to a Python script. ``argv[0]`` is the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
16 script name (it is operating system dependent whether this is a full pathname or
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
17 not). If the command was executed using the :option:`-c` command line option to
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
18 the interpreter, ``argv[0]`` is set to the string ``'-c'``. If no script name
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
19 was passed to the Python interpreter, ``argv[0]`` is the empty string.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
20
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
21 To loop over the standard input, or the list of files given on the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
22 command line, see the :mod:`fileinput` module.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
23
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
24
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
25 .. data:: byteorder
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
26
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
27 An indicator of the native byte order. This will have the value ``'big'`` on
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
28 big-endian (most-significant byte first) platforms, and ``'little'`` on
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
29 little-endian (least-significant byte first) platforms.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
30
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
31 .. versionadded:: 2.0
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
32
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
33
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
34 .. data:: builtin_module_names
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
35
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
36 A tuple of strings giving the names of all modules that are compiled into this
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
37 Python interpreter. (This information is not available in any other way ---
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
38 ``modules.keys()`` only lists the imported modules.)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
39
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
40
66457
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
41 .. function:: call_tracing(func, args)
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
42
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
43 Call ``func(*args)``, while tracing is enabled. The tracing state is saved,
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
44 and restored afterwards. This is intended to be called from a debugger from
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
45 a checkpoint, to recursively debug some other code.
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
46
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
47
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
48 .. data:: copyright
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
49
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
50 A string containing the copyright pertaining to the Python interpreter.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
51
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
52
45143
8fdd6d62ea55 Patch #1953
Christian Heimes <christian@cheimes.de>
parents: 45025
diff changeset
53 .. function:: _clear_type_cache()
8fdd6d62ea55 Patch #1953
Christian Heimes <christian@cheimes.de>
parents: 45025
diff changeset
54
8fdd6d62ea55 Patch #1953
Christian Heimes <christian@cheimes.de>
parents: 45025
diff changeset
55 Clear the internal type cache. The type cache is used to speed up attribute
8fdd6d62ea55 Patch #1953
Christian Heimes <christian@cheimes.de>
parents: 45025
diff changeset
56 and method lookups. Use the function *only* to drop unnecessary references
8fdd6d62ea55 Patch #1953
Christian Heimes <christian@cheimes.de>
parents: 45025
diff changeset
57 during reference leak debugging.
8fdd6d62ea55 Patch #1953
Christian Heimes <christian@cheimes.de>
parents: 45025
diff changeset
58
8fdd6d62ea55 Patch #1953
Christian Heimes <christian@cheimes.de>
parents: 45025
diff changeset
59 This function should be used for internal and specialized purposes only.
45025
ea3fe302d392 Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents: 44822
diff changeset
60
ea3fe302d392 Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents: 44822
diff changeset
61 .. versionadded:: 2.6
ea3fe302d392 Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents: 44822
diff changeset
62
ea3fe302d392 Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Christian Heimes <christian@cheimes.de>
parents: 44822
diff changeset
63
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
64 .. function:: _current_frames()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
65
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
66 Return a dictionary mapping each thread's identifier to the topmost stack frame
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
67 currently active in that thread at the time the function is called. Note that
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
68 functions in the :mod:`traceback` module can build the call stack given such a
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
69 frame.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
70
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
71 This is most useful for debugging deadlock: this function does not require the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
72 deadlocked threads' cooperation, and such threads' call stacks are frozen for as
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
73 long as they remain deadlocked. The frame returned for a non-deadlocked thread
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
74 may bear no relationship to that thread's current activity by the time calling
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
75 code examines the frame.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
76
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
77 This function should be used for internal and specialized purposes only.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
78
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
79 .. versionadded:: 2.5
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
80
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
81
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
82 .. data:: dllhandle
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
83
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
84 Integer specifying the handle of the Python DLL. Availability: Windows.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
85
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
86
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
87 .. function:: displayhook(value)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
88
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
89 If *value* is not ``None``, this function prints it to ``sys.stdout``, and saves
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
90 it in ``__builtin__._``.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
91
44103
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
92 ``sys.displayhook`` is called on the result of evaluating an :term:`expression`
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
93 entered in an interactive Python session. The display of these values can be
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
94 customized by assigning another one-argument function to ``sys.displayhook``.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
95
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
96
72722
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
97 .. data:: dont_write_bytecode
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
98
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
99 If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
100 import of source modules. This value is initially set to ``True`` or
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
101 ``False`` depending on the :option:`-B` command line option and the
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
102 :envvar:`PYTHONDONTWRITEBYTECODE` environment variable, but you can set it
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
103 yourself to control bytecode file generation.
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
104
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
105 .. versionadded:: 2.6
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
106
8ef2436b14ec Move doc of sys.dont_write_bytecode to make all attributes sorted again
Éric Araujo <merwok@netwok.org>
parents: 72293
diff changeset
107
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
108 .. function:: excepthook(type, value, traceback)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
109
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
110 This function prints out a given traceback and exception to ``sys.stderr``.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
111
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
112 When an exception is raised and uncaught, the interpreter calls
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
113 ``sys.excepthook`` with three arguments, the exception class, exception
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
114 instance, and a traceback object. In an interactive session this happens just
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
115 before control is returned to the prompt; in a Python program this happens just
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
116 before the program exits. The handling of such top-level exceptions can be
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
117 customized by assigning another three-argument function to ``sys.excepthook``.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
118
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
119
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
120 .. data:: __displayhook__
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
121 __excepthook__
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
122
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
123 These objects contain the original values of ``displayhook`` and ``excepthook``
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
124 at the start of the program. They are saved so that ``displayhook`` and
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
125 ``excepthook`` can be restored in case they happen to get replaced with broken
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
126 objects.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
127
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
128
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
129 .. function:: exc_info()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
130
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
131 This function returns a tuple of three values that give information about the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
132 exception that is currently being handled. The information returned is specific
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
133 both to the current thread and to the current stack frame. If the current stack
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
134 frame is not handling an exception, the information is taken from the calling
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
135 stack frame, or its caller, and so on until a stack frame is found that is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
136 handling an exception. Here, "handling an exception" is defined as "executing
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
137 or having executed an except clause." For any stack frame, only information
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
138 about the most recently handled exception is accessible.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
139
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
140 .. index:: object: traceback
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
141
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
142 If no exception is being handled anywhere on the stack, a tuple containing three
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
143 ``None`` values is returned. Otherwise, the values returned are ``(type, value,
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
144 traceback)``. Their meaning is: *type* gets the exception type of the exception
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
145 being handled (a class object); *value* gets the exception parameter (its
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
146 :dfn:`associated value` or the second argument to :keyword:`raise`, which is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
147 always a class instance if the exception type is a class object); *traceback*
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
148 gets a traceback object (see the Reference Manual) which encapsulates the call
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
149 stack at the point where the exception originally occurred.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
150
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
151 If :func:`exc_clear` is called, this function will return three ``None`` values
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
152 until either another exception is raised in the current thread or the execution
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
153 stack returns to a frame where another exception is being handled.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
154
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
155 .. warning::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
156
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
157 Assigning the *traceback* return value to a local variable in a function that is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
158 handling an exception will cause a circular reference. This will prevent
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
159 anything referenced by a local variable in the same function or by the traceback
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
160 from being garbage collected. Since most functions don't need access to the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
161 traceback, the best solution is to use something like ``exctype, value =
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
162 sys.exc_info()[:2]`` to extract only the exception type and value. If you do
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
163 need the traceback, make sure to delete it after use (best done with a
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
164 :keyword:`try` ... :keyword:`finally` statement) or to call :func:`exc_info` in
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
165 a function that does not itself handle an exception.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
166
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
167 .. note::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
168
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
169 Beginning with Python 2.2, such cycles are automatically reclaimed when garbage
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
170 collection is enabled and they become unreachable, but it remains more efficient
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
171 to avoid creating cycles.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
172
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
173
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
174 .. function:: exc_clear()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
175
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
176 This function clears all information relating to the current or last exception
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
177 that occurred in the current thread. After calling this function,
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
178 :func:`exc_info` will return three ``None`` values until another exception is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
179 raised in the current thread or the execution stack returns to a frame where
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
180 another exception is being handled.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
181
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
182 This function is only needed in only a few obscure situations. These include
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
183 logging and error handling systems that report information on the last or
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
184 current exception. This function can also be used to try to free resources and
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
185 trigger object finalization, though no guarantee is made as to what objects will
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
186 be freed, if any.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
187
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
188 .. versionadded:: 2.3
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
189
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
190
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
191 .. data:: exc_type
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
192 exc_value
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
193 exc_traceback
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
194
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
195 .. deprecated:: 1.5
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
196 Use :func:`exc_info` instead.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
197
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
198 Since they are global variables, they are not specific to the current thread, so
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
199 their use is not safe in a multi-threaded program. When no exception is being
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
200 handled, ``exc_type`` is set to ``None`` and the other two are undefined.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
201
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
202
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
203 .. data:: exec_prefix
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
204
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
205 A string giving the site-specific directory prefix where the platform-dependent
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
206 Python files are installed; by default, this is also ``'/usr/local'``. This can
66962
59e230297bff Merged revisions 86521,86632,86823-86824,87294,87296,87300,87302 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 66457
diff changeset
207 be set at build time with the ``--exec-prefix`` argument to the
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
208 :program:`configure` script. Specifically, all configuration files (e.g. the
72723
9f6704da4abb Fix markup used in the documentation of sys.prefix and sys.exec_prefix.
Éric Araujo <merwok@netwok.org>
parents: 72722
diff changeset
209 :file:`pyconfig.h` header file) are installed in the directory
75278
ca6455c919e7 Fix markup errors
Éric Araujo <merwok@netwok.org>
parents: 75102
diff changeset
210 :file:`{exec_prefix}/lib/python{X.Y}/config`, and shared library modules are
72723
9f6704da4abb Fix markup used in the documentation of sys.prefix and sys.exec_prefix.
Éric Araujo <merwok@netwok.org>
parents: 72722
diff changeset
211 installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y*
9f6704da4abb Fix markup used in the documentation of sys.prefix and sys.exec_prefix.
Éric Araujo <merwok@netwok.org>
parents: 72722
diff changeset
212 is the version number of Python, for example ``2.7``.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
213
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
214
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
215 .. data:: executable
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
216
74728
c351536e804a Document absoluteness of sys.executable
Petri Lehtinen <petri@digip.org>
parents: 74397
diff changeset
217 A string giving the absolute path of the executable binary for the Python
c351536e804a Document absoluteness of sys.executable
Petri Lehtinen <petri@digip.org>
parents: 74397
diff changeset
218 interpreter, on systems where this makes sense. If Python is unable to retrieve
c351536e804a Document absoluteness of sys.executable
Petri Lehtinen <petri@digip.org>
parents: 74397
diff changeset
219 the real path to its executable, :data:`sys.executable` will be an empty string
c351536e804a Document absoluteness of sys.executable
Petri Lehtinen <petri@digip.org>
parents: 74397
diff changeset
220 or ``None``.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
221
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
222
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
223 .. function:: exit([arg])
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
224
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
225 Exit from Python. This is implemented by raising the :exc:`SystemExit`
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
226 exception, so cleanup actions specified by finally clauses of :keyword:`try`
66457
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
227 statements are honored, and it is possible to intercept the exit attempt at
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
228 an outer level.
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
229
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
230 The optional argument *arg* can be an integer giving the exit status
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
231 (defaulting to zero), or another type of object. If it is an integer, zero
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
232 is considered "successful termination" and any nonzero value is considered
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
233 "abnormal termination" by shells and the like. Most systems require it to be
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
234 in the range 0-127, and produce undefined results otherwise. Some systems
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
235 have a convention for assigning specific meanings to specific exit codes, but
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
236 these are generally underdeveloped; Unix programs generally use 2 for command
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
237 line syntax errors and 1 for all other kind of errors. If another type of
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
238 object is passed, ``None`` is equivalent to passing zero, and any other
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
239 object is printed to :data:`stderr` and results in an exit code of 1. In
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
240 particular, ``sys.exit("some error message")`` is a quick way to exit a
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
241 program when an error occurs.
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
242
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
243 Since :func:`exit` ultimately "only" raises an exception, it will only exit
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
244 the process when called from the main thread, and the exception is not
a803fd841fd1 Merged revisions 85617-85622,85624,85626-85627,85629,85631,85635-85636,85638-85639,85641-85642 via svnmerge from
Georg Brandl <georg@python.org>
parents: 66453
diff changeset
245 intercepted.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
246
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
247
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
248 .. data:: exitfunc
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
249
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
250 This value is not actually defined by the module, but can be set by the user (or
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
251 by a program) to specify a clean-up action at program exit. When set, it should
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
252 be a parameterless function. This function will be called when the interpreter
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
253 exits. Only one function may be installed in this way; to allow multiple
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
254 functions which will be called at termination, use the :mod:`atexit` module.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
255
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
256 .. note::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
257
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
258 The exit function is not called when the program is killed by a signal, when a
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
259 Python fatal internal error is detected, or when ``os._exit()`` is called.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
260
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
261 .. deprecated:: 2.4
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
262 Use :mod:`atexit` instead.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
263
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
264
44669
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
265 .. data:: flags
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
266
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
267 The struct sequence *flags* exposes the status of command line flags. The
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
268 attributes are read only.
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
269
68958
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
270 ============================= ===================================
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
271 attribute flag
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
272 ============================= ===================================
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
273 :const:`debug` :option:`-d`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
274 :const:`py3k_warning` :option:`-3`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
275 :const:`division_warning` :option:`-Q`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
276 :const:`division_new` :option:`-Qnew <-Q>`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
277 :const:`inspect` :option:`-i`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
278 :const:`interactive` :option:`-i`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
279 :const:`optimize` :option:`-O` or :option:`-OO`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
280 :const:`dont_write_bytecode` :option:`-B`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
281 :const:`no_user_site` :option:`-s`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
282 :const:`no_site` :option:`-S`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
283 :const:`ignore_environment` :option:`-E`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
284 :const:`tabcheck` :option:`-t` or :option:`-tt <-t>`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
285 :const:`verbose` :option:`-v`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
286 :const:`unicode` :option:`-U`
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
287 :const:`bytes_warning` :option:`-b`
75102
a0f43f4481e0 merge 2.6 with hash randomization fix
Benjamin Peterson <benjamin@python.org>
parents: 74728 75100
diff changeset
288 :const:`hash_randomization` :option:`-R`
68958
814599728ac0 Tweaks to sys.flags description table.
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
289 ============================= ===================================
44669
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
290
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
291 .. versionadded:: 2.6
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
292
75279
26a4cb0ff7c0 Add versionadded for sys.flags.hash_randomization variable
Éric Araujo <merwok@netwok.org>
parents: 75278
diff changeset
293 .. versionadded:: 2.7.3
26a4cb0ff7c0 Add versionadded for sys.flags.hash_randomization variable
Éric Araujo <merwok@netwok.org>
parents: 75278
diff changeset
294 The ``hash_randomization`` attribute.
44669
9b6d348cec87 Applied patch #1816: sys.flags patch
Christian Heimes <christian@cheimes.de>
parents: 44566
diff changeset
295
44085
c218d1ac916e Feature #1534
Christian Heimes <christian@cheimes.de>
parents: 44041
diff changeset
296 .. data:: float_info
c218d1ac916e Feature #1534
Christian Heimes <christian@cheimes.de>
parents: 44041
diff changeset
297
44670
d66e5837aa57 Now that I've learnt about structseq objects I felt like converting sys.float_info to a structseq. It's
Christian Heimes <christian@cheimes.de>
parents: 44669
diff changeset
298 A structseq holding information about the float type. It contains low level
62693
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
299 information about the precision and internal representation. The values
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
300 correspond to the various floating-point constants defined in the standard
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
301 header file :file:`float.h` for the 'C' programming language; see section
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
302 5.2.4.2.2 of the 1999 ISO/IEC C standard [C99]_, 'Characteristics of
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
303 floating types', for details.
44085
c218d1ac916e Feature #1534
Christian Heimes <christian@cheimes.de>
parents: 44041
diff changeset
304
62693
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
305 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
306 | attribute | float.h macro | explanation |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
307 +=====================+================+==================================================+
62718
cc4bd766fe10 Merged revisions 82476 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 62693
diff changeset
308 | :const:`epsilon` | DBL_EPSILON | difference between 1 and the least value greater |
62693
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
309 | | | than 1 that is representable as a float |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
310 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
311 | :const:`dig` | DBL_DIG | maximum number of decimal digits that can be |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
312 | | | faithfully represented in a float; see below |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
313 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
314 | :const:`mant_dig` | DBL_MANT_DIG | float precision: the number of base-``radix`` |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
315 | | | digits in the significand of a float |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
316 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
317 | :const:`max` | DBL_MAX | maximum representable finite float |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
318 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
319 | :const:`max_exp` | DBL_MAX_EXP | maximum integer e such that ``radix**(e-1)`` is |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
320 | | | a representable finite float |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
321 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
322 | :const:`max_10_exp` | DBL_MAX_10_EXP | maximum integer e such that ``10**e`` is in the |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
323 | | | range of representable finite floats |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
324 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
325 | :const:`min` | DBL_MIN | minimum positive normalized float |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
326 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
327 | :const:`min_exp` | DBL_MIN_EXP | minimum integer e such that ``radix**(e-1)`` is |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
328 | | | a normalized float |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
329 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
330 | :const:`min_10_exp` | DBL_MIN_10_EXP | minimum integer e such that ``10**e`` is a |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
331 | | | normalized float |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
332 +---------------------+----------------+--------------------------------------------------+
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
333 | :const:`radix` | FLT_RADIX | radix of exponent representation |
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
334 +---------------------+----------------+--------------------------------------------------+
73620
de1ecda2afa2 Issue #12245: Document sys.float_info.rounds better.
Mark Dickinson <mdickinson@enthought.com>
parents: 72723
diff changeset
335 | :const:`rounds` | FLT_ROUNDS | integer constant representing the rounding mode |
de1ecda2afa2 Issue #12245: Document sys.float_info.rounds better.
Mark Dickinson <mdickinson@enthought.com>
parents: 72723
diff changeset
336 | | | used for arithmetic operations. This reflects |
de1ecda2afa2 Issue #12245: Document sys.float_info.rounds better.
Mark Dickinson <mdickinson@enthought.com>
parents: 72723
diff changeset
337 | | | the value of the system FLT_ROUNDS macro at |
de1ecda2afa2 Issue #12245: Document sys.float_info.rounds better.
Mark Dickinson <mdickinson@enthought.com>
parents: 72723
diff changeset
338 | | | interpreter startup time. See section 5.2.4.2.2 |
de1ecda2afa2 Issue #12245: Document sys.float_info.rounds better.
Mark Dickinson <mdickinson@enthought.com>
parents: 72723
diff changeset
339 | | | of the C99 standard for an explanation of the |
de1ecda2afa2 Issue #12245: Document sys.float_info.rounds better.
Mark Dickinson <mdickinson@enthought.com>
parents: 72723
diff changeset
340 | | | possible values and their meanings. |
62693
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
341 +---------------------+----------------+--------------------------------------------------+
44085
c218d1ac916e Feature #1534
Christian Heimes <christian@cheimes.de>
parents: 44041
diff changeset
342
62693
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
343 The attribute :attr:`sys.float_info.dig` needs further explanation. If
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
344 ``s`` is any string representing a decimal number with at most
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
345 :attr:`sys.float_info.dig` significant digits, then converting ``s`` to a
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
346 float and back again will recover a string representing the same decimal
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
347 value::
44085
c218d1ac916e Feature #1534
Christian Heimes <christian@cheimes.de>
parents: 44041
diff changeset
348
62693
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
349 >>> import sys
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
350 >>> sys.float_info.dig
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
351 15
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
352 >>> s = '3.14159265358979' # decimal string with 15 significant digits
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
353 >>> format(float(s), '.15g') # convert to float and back -> same value
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
354 '3.14159265358979'
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
355
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
356 But for strings with more than :attr:`sys.float_info.dig` significant digits,
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
357 this isn't always true::
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
358
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
359 >>> s = '9876543211234567' # 16 significant digits is too many!
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
360 >>> format(float(s), '.16g') # conversion changes value
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
361 '9876543211234568'
44085
c218d1ac916e Feature #1534
Christian Heimes <christian@cheimes.de>
parents: 44041
diff changeset
362
44089
21321dcf0ab5 Added one more missing versionadded tag
Christian Heimes <christian@cheimes.de>
parents: 44085
diff changeset
363 .. versionadded:: 2.6
21321dcf0ab5 Added one more missing versionadded tag
Christian Heimes <christian@cheimes.de>
parents: 44085
diff changeset
364
56715
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
365 .. data:: float_repr_style
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
366
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
367 A string indicating how the :func:`repr` function behaves for
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
368 floats. If the string has value ``'short'`` then for a finite
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
369 float ``x``, ``repr(x)`` aims to produce a short string with the
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
370 property that ``float(repr(x)) == x``. This is the usual behaviour
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
371 in Python 2.7 and later. Otherwise, ``float_repr_style`` has value
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
372 ``'legacy'`` and ``repr(x)`` behaves in the same way as it did in
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
373 versions of Python prior to 2.7.
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
374
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
375 .. versionadded:: 2.7
aacee9749d15 Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents: 56671
diff changeset
376
44085
c218d1ac916e Feature #1534
Christian Heimes <christian@cheimes.de>
parents: 44041
diff changeset
377
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
378 .. function:: getcheckinterval()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
379
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
380 Return the interpreter's "check interval"; see :func:`setcheckinterval`.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
381
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
382 .. versionadded:: 2.3
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
383
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
384
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
385 .. function:: getdefaultencoding()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
386
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
387 Return the name of the current default string encoding used by the Unicode
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
388 implementation.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
389
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
390 .. versionadded:: 2.0
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
391
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
392
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
393 .. function:: getdlopenflags()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
394
74395
74ff71b2f53d update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents: 73620
diff changeset
395 Return the current value of the flags that are used for :c:func:`dlopen` calls.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
396 The flag constants are defined in the :mod:`dl` and :mod:`DLFCN` modules.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
397 Availability: Unix.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
398
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
399 .. versionadded:: 2.2
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
400
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
401
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
402 .. function:: getfilesystemencoding()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
403
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
404 Return the name of the encoding used to convert Unicode filenames into system
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
405 file names, or ``None`` if the system default encoding is used. The result value
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
406 depends on the operating system:
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
407
61094
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
408 * On Mac OS X, the encoding is ``'utf-8'``.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
409
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
410 * On Unix, the encoding is the user's preference according to the result of
61094
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
411 nl_langinfo(CODESET), or ``None`` if the ``nl_langinfo(CODESET)``
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
412 failed.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
413
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
414 * On Windows NT+, file names are Unicode natively, so no conversion is
61094
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
415 performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
416 this is the encoding that applications should use when they explicitly
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
417 want to convert Unicode strings to byte strings that are equivalent when
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
418 used as file names.
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
419
47fc6fe5e454 Merged revisions 80620 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59845
diff changeset
420 * On Windows 9x, the encoding is ``'mbcs'``.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
421
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
422 .. versionadded:: 2.3
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
423
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
424
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
425 .. function:: getrefcount(object)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
426
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
427 Return the reference count of the *object*. The count returned is generally one
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
428 higher than you might expect, because it includes the (temporary) reference as
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
429 an argument to :func:`getrefcount`.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
430
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
431
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
432 .. function:: getrecursionlimit()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
433
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
434 Return the current value of the recursion limit, the maximum depth of the Python
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
435 interpreter stack. This limit prevents infinite recursion from causing an
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
436 overflow of the C stack and crashing Python. It can be set by
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
437 :func:`setrecursionlimit`.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
438
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
439
47925
fd054e73e2f2 Added garbage collector overhead and optional default return value to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47897
diff changeset
440 .. function:: getsizeof(object[, default])
47419
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
441
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
442 Return the size of an object in bytes. The object can be any type of
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
443 object. All built-in objects will return correct results, but this
47925
fd054e73e2f2 Added garbage collector overhead and optional default return value to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47897
diff changeset
444 does not have to hold true for third-party extensions as it is implementation
47419
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
445 specific.
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
446
56197
68899dc117eb Merged revisions 75032 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 56189
diff changeset
447 If given, *default* will be returned if the object does not provide means to
59845
f96c8293dd7f Merged revisions 78859-78860,78952,79168-79169,79173,79176,79178-79179,79181,79184-79185,79192,79212 via svnmerge from
Georg Brandl <georg@python.org>
parents: 57933
diff changeset
448 retrieve the size. Otherwise a :exc:`TypeError` will be raised.
47925
fd054e73e2f2 Added garbage collector overhead and optional default return value to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47897
diff changeset
449
56197
68899dc117eb Merged revisions 75032 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 56189
diff changeset
450 :func:`getsizeof` calls the object's ``__sizeof__`` method and adds an
68899dc117eb Merged revisions 75032 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 56189
diff changeset
451 additional garbage collector overhead if the object is managed by the garbage
68899dc117eb Merged revisions 75032 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 56189
diff changeset
452 collector.
47925
fd054e73e2f2 Added garbage collector overhead and optional default return value to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47897
diff changeset
453
47419
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
454 .. versionadded:: 2.6
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
455
88bd07c0a847 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 47194
diff changeset
456
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
457 .. function:: _getframe([depth])
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
458
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
459 Return a frame object from the call stack. If optional integer *depth* is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
460 given, return the frame object that many calls below the top of the stack. If
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
461 that is deeper than the call stack, :exc:`ValueError` is raised. The default
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
462 for *depth* is zero, returning the frame at the top of the call stack.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
463
56824
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
464 .. impl-detail::
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
465
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
466 This function should be used for internal and specialized purposes only.
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
467 It is not guaranteed to exist in all implementations of Python.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
468
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
469
44822
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
470 .. function:: getprofile()
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
471
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
472 .. index::
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
473 single: profile function
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
474 single: profiler
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
475
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
476 Get the profiler function as set by :func:`setprofile`.
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
477
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
478 .. versionadded:: 2.6
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
479
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
480
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
481 .. function:: gettrace()
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
482
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
483 .. index::
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
484 single: trace function
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
485 single: debugger
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
486
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
487 Get the trace function as set by :func:`settrace`.
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
488
56824
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
489 .. impl-detail::
44822
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
490
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
491 The :func:`gettrace` function is intended only for implementing debuggers,
56824
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
492 profilers, coverage tools and the like. Its behavior is part of the
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
493 implementation platform, rather than part of the language definition, and
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
494 thus may not be available in all Python implementations.
44822
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
495
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
496 .. versionadded:: 2.6
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
497
424cccfd2baa #1648: add sys.gettrace() and sys.getprofile().
Georg Brandl <georg@python.org>
parents: 44820
diff changeset
498
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
499 .. function:: getwindowsversion()
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
500
58509
92e6e8d904a2 Fix type on getwindowsversion documentation. Thanks Taggnostr.
Eric Smith <eric@trueblade.com>
parents: 58505
diff changeset
501 Return a named tuple describing the Windows version
58505
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
502 currently running. The named elements are *major*, *minor*,
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
503 *build*, *platform*, *service_pack*, *service_pack_minor*,
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
504 *service_pack_major*, *suite_mask*, and *product_type*.
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
505 *service_pack* contains a string while all other values are
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
506 integers. The components can also be accessed by name, so
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
507 ``sys.getwindowsversion()[0]`` is equivalent to
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
508 ``sys.getwindowsversion().major``. For compatibility with prior
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
509 versions, only the first 5 elements are retrievable by indexing.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
510
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
511 *platform* may be one of the following values:
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
512
46522
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
513 +-----------------------------------------+-------------------------+
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
514 | Constant | Platform |
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
515 +=========================================+=========================+
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
516 | :const:`0 (VER_PLATFORM_WIN32s)` | Win32s on Windows 3.1 |
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
517 +-----------------------------------------+-------------------------+
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
518 | :const:`1 (VER_PLATFORM_WIN32_WINDOWS)` | Windows 95/98/ME |
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
519 +-----------------------------------------+-------------------------+
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
520 | :const:`2 (VER_PLATFORM_WIN32_NT)` | Windows NT/2000/XP/x64 |
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
521 +-----------------------------------------+-------------------------+
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
522 | :const:`3 (VER_PLATFORM_WIN32_CE)` | Windows CE |
b7df30ac5b5a Windows x64 also falls under VER_PLATFORM_WIN32_NT.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents: 45990
diff changeset
523 +-----------------------------------------+-------------------------+
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
524
58505
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
525 *product_type* may be one of the following values:
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
526
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
527 +---------------------------------------+---------------------------------+
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
528 | Constant | Meaning |
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
529 +=======================================+=================================+
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
530 | :const:`1 (VER_NT_WORKSTATION)` | The system is a workstation. |
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
531 +---------------------------------------+---------------------------------+
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
532 | :const:`2 (VER_NT_DOMAIN_CONTROLLER)` | The system is a domain |
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
533 | | controller. |
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
534 +---------------------------------------+---------------------------------+
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
535 | :const:`3 (VER_NT_SERVER)` | The system is a server, but not |
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
536 | | a domain controller. |
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
537 +---------------------------------------+---------------------------------+
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
538
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
539
74395
74ff71b2f53d update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents: 73620
diff changeset
540 This function wraps the Win32 :c:func:`GetVersionEx` function; see the
74ff71b2f53d update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents: 73620
diff changeset
541 Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information
58505
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
542 about these fields.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
543
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
544 Availability: Windows.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
545
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
546 .. versionadded:: 2.3
58505
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
547 .. versionchanged:: 2.7
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
548 Changed to a named tuple and added *service_pack_minor*,
bc2b88beae45 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type.
Eric Smith <eric@trueblade.com>
parents: 57932
diff changeset
549 *service_pack_major*, *suite_mask*, and *product_type*.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
550
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
551
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
552 .. data:: hexversion
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
553
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
554 The version number encoded as a single integer. This is guaranteed to increase
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
555 with each version, including proper support for non-production releases. For
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
556 example, to test that the Python interpreter is at least version 1.5.2, use::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
557
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
558 if sys.hexversion >= 0x010502F0:
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
559 # use some advanced feature
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
560 ...
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
561 else:
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
562 # use an alternative implementation or warn the user
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
563 ...
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
564
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
565 This is called ``hexversion`` since it only really looks meaningful when viewed
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
566 as the result of passing it to the built-in :func:`hex` function. The
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
567 ``version_info`` value may be used for a more human-friendly encoding of the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
568 same information.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
569
69717
34d2fb56de9a #11901: post-commit review fixes per Georg Brandl
R David Murray <rdmurray@bitdance.com>
parents: 69558
diff changeset
570 The ``hexversion`` is a 32-bit number with the following layout:
69558
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
571
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
572 +-------------------------+------------------------------------------------+
69717
34d2fb56de9a #11901: post-commit review fixes per Georg Brandl
R David Murray <rdmurray@bitdance.com>
parents: 69558
diff changeset
573 | Bits (big endian order) | Meaning |
69558
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
574 +=========================+================================================+
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
575 | :const:`1-8` | ``PY_MAJOR_VERSION`` (the ``2`` in |
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
576 | | ``2.1.0a3``) |
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
577 +-------------------------+------------------------------------------------+
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
578 | :const:`9-16` | ``PY_MINOR_VERSION`` (the ``1`` in |
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
579 | | ``2.1.0a3``) |
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
580 +-------------------------+------------------------------------------------+
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
581 | :const:`17-24` | ``PY_MICRO_VERSION`` (the ``0`` in |
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
582 | | ``2.1.0a3``) |
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
583 +-------------------------+------------------------------------------------+
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
584 | :const:`25-28` | ``PY_RELEASE_LEVEL`` (``0xA`` for alpha, |
69717
34d2fb56de9a #11901: post-commit review fixes per Georg Brandl
R David Murray <rdmurray@bitdance.com>
parents: 69558
diff changeset
585 | | ``0xB`` for beta, ``0xC`` for release |
34d2fb56de9a #11901: post-commit review fixes per Georg Brandl
R David Murray <rdmurray@bitdance.com>
parents: 69558
diff changeset
586 | | candidate and ``0xF`` for final) |
69558
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
587 +-------------------------+------------------------------------------------+
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
588 | :const:`29-32` | ``PY_RELEASE_SERIAL`` (the ``3`` in |
69717
34d2fb56de9a #11901: post-commit review fixes per Georg Brandl
R David Murray <rdmurray@bitdance.com>
parents: 69558
diff changeset
589 | | ``2.1.0a3``, zero for final releases) |
69558
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
590 +-------------------------+------------------------------------------------+
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
591
69717
34d2fb56de9a #11901: post-commit review fixes per Georg Brandl
R David Murray <rdmurray@bitdance.com>
parents: 69558
diff changeset
592 Thus ``2.1.0a3`` is hexversion ``0x020100a3``.
69558
48758cd0769b #11901: add description of how bitfields are laid out to hexversion docs
R David Murray <rdmurray@bitdance.com>
parents: 68958
diff changeset
593
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
594 .. versionadded:: 1.5.2
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
595
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
596
52233
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
597 .. data:: long_info
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
598
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
599 A struct sequence that holds information about Python's
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
600 internal representation of integers. The attributes are read only.
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
601
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
602 +-------------------------+----------------------------------------------+
69717
34d2fb56de9a #11901: post-commit review fixes per Georg Brandl
R David Murray <rdmurray@bitdance.com>
parents: 69558
diff changeset
603 | Attribute | Explanation |
52233
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
604 +=========================+==============================================+
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
605 | :const:`bits_per_digit` | number of bits held in each digit. Python |
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
606 | | integers are stored internally in base |
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
607 | | ``2**long_info.bits_per_digit`` |
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
608 +-------------------------+----------------------------------------------+
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
609 | :const:`sizeof_digit` | size in bytes of the C type used to |
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
610 | | represent a digit |
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
611 +-------------------------+----------------------------------------------+
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
612
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
613 .. versionadded:: 2.7
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
614
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 51870
diff changeset
615
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
616 .. data:: last_type
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
617 last_value
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
618 last_traceback
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
619
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
620 These three variables are not always defined; they are set when an exception is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
621 not handled and the interpreter prints an error message and a stack traceback.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
622 Their intended use is to allow an interactive user to import a debugger module
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
623 and engage in post-mortem debugging without having to re-execute the command
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
624 that caused the error. (Typical use is ``import pdb; pdb.pm()`` to enter the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
625 post-mortem debugger; see chapter :ref:`debugger` for
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
626 more information.)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
627
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
628 The meaning of the variables is the same as that of the return values from
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
629 :func:`exc_info` above. (Since there is only one interactive thread,
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
630 thread-safety is not a concern for these variables, unlike for ``exc_type``
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
631 etc.)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
632
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
633
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
634 .. data:: maxint
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
635
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
636 The largest positive integer supported by Python's regular integer type. This
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
637 is at least 2\*\*31-1. The largest negative integer is ``-maxint-1`` --- the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
638 asymmetry results from the use of 2's complement binary arithmetic.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
639
47194
59ab2cf002fa Patch #2488: Add sys.maxsize.
Martin v. Löwis <martin@v.loewis.de>
parents: 46522
diff changeset
640 .. data:: maxsize
59ab2cf002fa Patch #2488: Add sys.maxsize.
Martin v. Löwis <martin@v.loewis.de>
parents: 46522
diff changeset
641
59ab2cf002fa Patch #2488: Add sys.maxsize.
Martin v. Löwis <martin@v.loewis.de>
parents: 46522
diff changeset
642 The largest positive integer supported by the platform's Py_ssize_t type,
59ab2cf002fa Patch #2488: Add sys.maxsize.
Martin v. Löwis <martin@v.loewis.de>
parents: 46522
diff changeset
643 and thus the maximum size lists, strings, dicts, and many other containers
59ab2cf002fa Patch #2488: Add sys.maxsize.
Martin v. Löwis <martin@v.loewis.de>
parents: 46522
diff changeset
644 can have.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
645
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
646 .. data:: maxunicode
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
647
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
648 An integer giving the largest supported code point for a Unicode character. The
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
649 value of this depends on the configuration option that specifies whether Unicode
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
650 characters are stored as UCS-2 or UCS-4.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
651
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
652
52898
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
653 .. data:: meta_path
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
654
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
655 A list of :term:`finder` objects that have their :meth:`find_module`
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
656 methods called to see if one of the objects can find the module to be
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
657 imported. The :meth:`find_module` method is called at least with the
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
658 absolute name of the module being imported. If the module to be imported is
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
659 contained in package then the parent package's :attr:`__path__` attribute
74397
ae6e75bd5f36 None is not a keyword, link file.next() to functions.html#next
Sandro Tosi <sandro.tosi@gmail.com>
parents: 74395
diff changeset
660 is passed in as a second argument. The method returns ``None`` if
52898
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
661 the module cannot be found, else returns a :term:`loader`.
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
662
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
663 :data:`sys.meta_path` is searched before any implicit default finders or
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
664 :data:`sys.path`.
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
665
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
666 See :pep:`302` for the original specification.
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
667
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
668
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
669 .. data:: modules
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
670
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
671 .. index:: builtin: reload
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
672
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
673 This is a dictionary that maps module names to modules which have already been
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
674 loaded. This can be manipulated to force reloading of modules and other tricks.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
675 Note that removing a module from this dictionary is *not* the same as calling
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
676 :func:`reload` on the corresponding module object.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
677
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
678
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
679 .. data:: path
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
680
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
681 .. index:: triple: module; search; path
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
682
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
683 A list of strings that specifies the search path for modules. Initialized from
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
684 the environment variable :envvar:`PYTHONPATH`, plus an installation-dependent
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
685 default.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
686
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
687 As initialized upon program startup, the first item of this list, ``path[0]``,
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
688 is the directory containing the script that was used to invoke the Python
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
689 interpreter. If the script directory is not available (e.g. if the interpreter
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
690 is invoked interactively or if the script is read from standard input),
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
691 ``path[0]`` is the empty string, which directs Python to search modules in the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
692 current directory first. Notice that the script directory is inserted *before*
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
693 the entries inserted as a result of :envvar:`PYTHONPATH`.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
694
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
695 A program is free to modify this list for its own purposes.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
696
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
697 .. versionchanged:: 2.3
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
698 Unicode strings are no longer ignored.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
699
50786
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50522
diff changeset
700 .. seealso::
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50522
diff changeset
701 Module :mod:`site` This describes how to use .pth files to extend
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50522
diff changeset
702 :data:`sys.path`.
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50522
diff changeset
703
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
704
52898
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
705 .. data:: path_hooks
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
706
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
707 A list of callables that take a path argument to try to create a
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
708 :term:`finder` for the path. If a finder can be created, it is to be
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
709 returned by the callable, else raise :exc:`ImportError`.
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
710
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
711 Originally specified in :pep:`302`.
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
712
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
713
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
714 .. data:: path_importer_cache
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
715
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
716 A dictionary acting as a cache for :term:`finder` objects. The keys are
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
717 paths that have been passed to :data:`sys.path_hooks` and the values are
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
718 the finders that are found. If a path is a valid file system path but no
74397
ae6e75bd5f36 None is not a keyword, link file.next() to functions.html#next
Sandro Tosi <sandro.tosi@gmail.com>
parents: 74395
diff changeset
719 explicit finder is found on :data:`sys.path_hooks` then ``None`` is
52898
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
720 stored to represent the implicit default finder should be used. If the path
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
721 is not an existing path then :class:`imp.NullImporter` is set.
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
722
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
723 Originally specified in :pep:`302`.
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
724
fb2ea8bb3a33 Merged revisions 70642,70648,70656,70661,70765,70773,70789,70824-70825,70828,70830,70832,70836,70838,70842,70851,70855,70857-70858 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50786
diff changeset
725
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
726 .. data:: platform
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
727
44820
145b3e605378 #799369: document possible sys.platform values.
Georg Brandl <georg@python.org>
parents: 44678
diff changeset
728 This string contains a platform identifier that can be used to append
145b3e605378 #799369: document possible sys.platform values.
Georg Brandl <georg@python.org>
parents: 44678
diff changeset
729 platform-specific components to :data:`sys.path`, for instance.
145b3e605378 #799369: document possible sys.platform values.
Georg Brandl <georg@python.org>
parents: 44678
diff changeset
730
72293
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
731 For most Unix systems, this is the lowercased OS name as returned by ``uname
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
732 -s`` with the first part of the version as returned by ``uname -r`` appended,
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
733 e.g. ``'sunos5'``, *at the time when Python was built*. Unless you want to
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
734 test for a specific system version, it is therefore recommended to use the
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
735 following idiom::
71284
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
736
72293
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
737 if sys.platform.startswith('freebsd'):
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
738 # FreeBSD-specific code here...
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
739 elif sys.platform.startswith('linux'):
71284
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
740 # Linux-specific code here...
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
741
72293
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
742 .. versionchanged:: 2.7.3
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
743 Since lots of code check for ``sys.platform == 'linux2'``, and there is
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
744 no essential change between Linux 2.x and 3.x, ``sys.platform`` is always
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
745 set to ``'linux2'``, even on Linux 3.x. In Python 3.3 and later, the
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
746 value will always be set to ``'linux'``, so it is recommended to always
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
747 use the ``startswith`` idiom presented above.
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
748
44820
145b3e605378 #799369: document possible sys.platform values.
Georg Brandl <georg@python.org>
parents: 44678
diff changeset
749 For other systems, the values are:
145b3e605378 #799369: document possible sys.platform values.
Georg Brandl <georg@python.org>
parents: 44678
diff changeset
750
72293
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
751 ===================== ===========================
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
752 System :data:`platform` value
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
753 ===================== ===========================
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
754 Linux (2.x *and* 3.x) ``'linux2'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
755 Windows ``'win32'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
756 Windows/Cygwin ``'cygwin'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
757 Mac OS X ``'darwin'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
758 OS/2 ``'os2'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
759 OS/2 EMX ``'os2emx'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
760 RiscOS ``'riscos'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
761 AtheOS ``'atheos'``
0fe571d43317 Update sys.platform doc for #12326.
Victor Stinner <victor.stinner@haypocalc.com>
parents: 71289
diff changeset
762 ===================== ===========================
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
763
71284
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
764 .. seealso::
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
765 :attr:`os.name` has a coarser granularity. :func:`os.uname` gives
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
766 system-dependent version information.
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
767
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
768 The :mod:`platform` module provides detailed checks for the
53d2d30d6ca0 Issue #12326: document the recommended idiom for checking sys.platform on Unix systems.
Antoine Pitrou <solipsis@pitrou.net>
parents: 69717
diff changeset
769 system's identity.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
770
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
771 .. data:: prefix
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
772
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
773 A string giving the site-specific directory prefix where the platform
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
774 independent Python files are installed; by default, this is the string
66962
59e230297bff Merged revisions 86521,86632,86823-86824,87294,87296,87300,87302 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 66457
diff changeset
775 ``'/usr/local'``. This can be set at build time with the ``--prefix``
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
776 argument to the :program:`configure` script. The main collection of Python
72723
9f6704da4abb Fix markup used in the documentation of sys.prefix and sys.exec_prefix.
Éric Araujo <merwok@netwok.org>
parents: 72722
diff changeset
777 library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}``
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
778 while the platform independent header files (all except :file:`pyconfig.h`) are
75278
ca6455c919e7 Fix markup errors
Éric Araujo <merwok@netwok.org>
parents: 75102
diff changeset
779 stored in :file:`{prefix}/include/python{X.Y}`, where *X.Y* is the version
72723
9f6704da4abb Fix markup used in the documentation of sys.prefix and sys.exec_prefix.
Éric Araujo <merwok@netwok.org>
parents: 72722
diff changeset
780 number of Python, for example ``2.7``.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
781
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
782
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
783 .. data:: ps1
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
784 ps2
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
785
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
786 .. index::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
787 single: interpreter prompts
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
788 single: prompts, interpreter
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
789
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
790 Strings specifying the primary and secondary prompt of the interpreter. These
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
791 are only defined if the interpreter is in interactive mode. Their initial
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
792 values in this case are ``'>>> '`` and ``'... '``. If a non-string object is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
793 assigned to either variable, its :func:`str` is re-evaluated each time the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
794 interpreter prepares to read a new interactive command; this can be used to
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
795 implement a dynamic prompt.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
796
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
797
44041
7e8e8797f9d0 Added py3kwarning to the documentation of the sys module.
Christian Heimes <christian@cheimes.de>
parents: 42603
diff changeset
798 .. data:: py3kwarning
7e8e8797f9d0 Added py3kwarning to the documentation of the sys module.
Christian Heimes <christian@cheimes.de>
parents: 42603
diff changeset
799
76732
8aab13719c02 Use Python 3 instead of 3.0.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 75279
diff changeset
800 Bool containing the status of the Python 3 warning flag. It's ``True``
52909
f3b26a729e82 Merged revisions 69578-69580,69901,69907,69994,70022-70023,70025-70026,70166,70273,70275,70342,70386-70387,70389-70390,70392-70393,70395,70397,70400,70418 via svnmerge
Georg Brandl <georg@python.org>
parents: 52900
diff changeset
801 when Python is started with the -3 option. (This should be considered
f3b26a729e82 Merged revisions 69578-69580,69901,69907,69994,70022-70023,70025-70026,70166,70273,70275,70342,70386-70387,70389-70390,70392-70393,70395,70397,70400,70418 via svnmerge
Georg Brandl <georg@python.org>
parents: 52900
diff changeset
802 read-only; setting it to a different value doesn't have an effect on
76732
8aab13719c02 Use Python 3 instead of 3.0.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 75279
diff changeset
803 Python 3 warnings.)
44041
7e8e8797f9d0 Added py3kwarning to the documentation of the sys module.
Christian Heimes <christian@cheimes.de>
parents: 42603
diff changeset
804
45990
2e3f86e73fa2 Add missing versionadded tag.
Georg Brandl <georg@python.org>
parents: 45143
diff changeset
805 .. versionadded:: 2.6
2e3f86e73fa2 Add missing versionadded tag.
Georg Brandl <georg@python.org>
parents: 45143
diff changeset
806
44041
7e8e8797f9d0 Added py3kwarning to the documentation of the sys module.
Christian Heimes <christian@cheimes.de>
parents: 42603
diff changeset
807
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
808 .. function:: setcheckinterval(interval)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
809
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
810 Set the interpreter's "check interval". This integer value determines how often
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
811 the interpreter checks for periodic things such as thread switches and signal
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
812 handlers. The default is ``100``, meaning the check is performed every 100
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
813 Python virtual instructions. Setting it to a larger value may increase
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
814 performance for programs using threads. Setting it to a value ``<=`` 0 checks
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
815 every virtual instruction, maximizing responsiveness as well as overhead.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
816
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
817
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
818 .. function:: setdefaultencoding(name)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
819
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
820 Set the current default string encoding used by the Unicode implementation. If
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
821 *name* does not match any available encoding, :exc:`LookupError` is raised.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
822 This function is only intended to be used by the :mod:`site` module
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
823 implementation and, where needed, by :mod:`sitecustomize`. Once used by the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
824 :mod:`site` module, it is removed from the :mod:`sys` module's namespace.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
825
44383
3625234bf3d2 Some cleanup in the docs.
Georg Brandl <georg@python.org>
parents: 44103
diff changeset
826 .. Note that :mod:`site` is not imported if the :option:`-S` option is passed
3625234bf3d2 Some cleanup in the docs.
Georg Brandl <georg@python.org>
parents: 44103
diff changeset
827 to the interpreter, in which case this function will remain available.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
828
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
829 .. versionadded:: 2.0
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
830
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
831
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
832 .. function:: setdlopenflags(n)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
833
74395
74ff71b2f53d update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents: 73620
diff changeset
834 Set the flags used by the interpreter for :c:func:`dlopen` calls, such as when
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
835 the interpreter loads extension modules. Among other things, this will enable a
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
836 lazy resolving of symbols when importing a module, if called as
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
837 ``sys.setdlopenflags(0)``. To share symbols across extension modules, call as
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
838 ``sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL)``. Symbolic names for the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
839 flag modules can be either found in the :mod:`dl` module, or in the :mod:`DLFCN`
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
840 module. If :mod:`DLFCN` is not available, it can be generated from
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
841 :file:`/usr/include/dlfcn.h` using the :program:`h2py` script. Availability:
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
842 Unix.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
843
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
844 .. versionadded:: 2.2
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
845
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
846
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
847 .. function:: setprofile(profilefunc)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
848
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
849 .. index::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
850 single: profile function
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
851 single: profiler
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
852
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
853 Set the system's profile function, which allows you to implement a Python source
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
854 code profiler in Python. See chapter :ref:`profile` for more information on the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
855 Python profiler. The system's profile function is called similarly to the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
856 system's trace function (see :func:`settrace`), but it isn't called for each
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
857 executed line of code (only on call and return, but the return event is reported
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
858 even when an exception has been set). The function is thread-specific, but
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
859 there is no way for the profiler to know about context switches between threads,
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
860 so it does not make sense to use this in the presence of multiple threads. Also,
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
861 its return value is not used, so it can simply return ``None``.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
862
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
863
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
864 .. function:: setrecursionlimit(limit)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
865
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
866 Set the maximum depth of the Python interpreter stack to *limit*. This limit
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
867 prevents infinite recursion from causing an overflow of the C stack and crashing
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
868 Python.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
869
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
870 The highest possible limit is platform-dependent. A user may need to set the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
871 limit higher when she has a program that requires deep recursion and a platform
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
872 that supports a higher limit. This should be done with care, because a too-high
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
873 limit can lead to a crash.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
874
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
875
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
876 .. function:: settrace(tracefunc)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
877
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
878 .. index::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
879 single: trace function
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
880 single: debugger
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
881
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
882 Set the system's trace function, which allows you to implement a Python
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
883 source code debugger in Python. The function is thread-specific; for a
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
884 debugger to support multiple threads, it must be registered using
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
885 :func:`settrace` for each thread being debugged.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
886
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
887 Trace functions should have three arguments: *frame*, *event*, and
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
888 *arg*. *frame* is the current stack frame. *event* is a string: ``'call'``,
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
889 ``'line'``, ``'return'``, ``'exception'``, ``'c_call'``, ``'c_return'``, or
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
890 ``'c_exception'``. *arg* depends on the event type.
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
891
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
892 The trace function is invoked (with *event* set to ``'call'``) whenever a new
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
893 local scope is entered; it should return a reference to a local trace
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
894 function to be used that scope, or ``None`` if the scope shouldn't be traced.
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
895
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
896 The local trace function should return a reference to itself (or to another
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
897 function for further tracing in that scope), or ``None`` to turn off tracing
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
898 in that scope.
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
899
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
900 The events have the following meaning:
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
901
50522
ee9ced92843a Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50002
diff changeset
902 ``'call'``
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
903 A function is called (or some other code block entered). The
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
904 global trace function is called; *arg* is ``None``; the return value
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
905 specifies the local trace function.
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
906
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
907 ``'line'``
54297
dddf424bd669 Issue #6042:
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 52566
diff changeset
908 The interpreter is about to execute a new line of code or re-execute the
dddf424bd669 Issue #6042:
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 52566
diff changeset
909 condition of a loop. The local trace function is called; *arg* is
dddf424bd669 Issue #6042:
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 52566
diff changeset
910 ``None``; the return value specifies the new local trace function. See
dddf424bd669 Issue #6042:
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 52566
diff changeset
911 :file:`Objects/lnotab_notes.txt` for a detailed explanation of how this
dddf424bd669 Issue #6042:
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 52566
diff changeset
912 works.
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
913
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
914 ``'return'``
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
915 A function (or other code block) is about to return. The local trace
66453
8ce9ae5a1542 Merged revisions 85530,85534,85538,85540-85542 via svnmerge from
Georg Brandl <georg@python.org>
parents: 65127
diff changeset
916 function is called; *arg* is the value that will be returned, or ``None``
8ce9ae5a1542 Merged revisions 85530,85534,85538,85540-85542 via svnmerge from
Georg Brandl <georg@python.org>
parents: 65127
diff changeset
917 if the event is caused by an exception being raised. The trace function's
8ce9ae5a1542 Merged revisions 85530,85534,85538,85540-85542 via svnmerge from
Georg Brandl <georg@python.org>
parents: 65127
diff changeset
918 return value is ignored.
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
919
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
920 ``'exception'``
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
921 An exception has occurred. The local trace function is called; *arg* is a
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
922 tuple ``(exception, value, traceback)``; the return value specifies the
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
923 new local trace function.
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
924
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
925 ``'c_call'``
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
926 A C function is about to be called. This may be an extension function or
56818
3e15a07a32fa Merged revisions 74209 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56197
diff changeset
927 a built-in. *arg* is the C function object.
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
928
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
929 ``'c_return'``
66453
8ce9ae5a1542 Merged revisions 85530,85534,85538,85540-85542 via svnmerge from
Georg Brandl <georg@python.org>
parents: 65127
diff changeset
930 A C function has returned. *arg* is the C function object.
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
931
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
932 ``'c_exception'``
66453
8ce9ae5a1542 Merged revisions 85530,85534,85538,85540-85542 via svnmerge from
Georg Brandl <georg@python.org>
parents: 65127
diff changeset
933 A C function has raised an exception. *arg* is the C function object.
50002
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
934
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
935 Note that as an exception is propagated down the chain of callers, an
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
936 ``'exception'`` event is generated at each level.
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
937
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
938 For more information on code and frame objects, refer to :ref:`types`.
5ef8b5a74efa Merged revisions 67245,67277,67289,67295,67301-67303,67307,67330,67332,67336,67355,67359,67362,67364,67367-67368,67370 via svnmerge from
Georg Brandl <georg@python.org>
parents: 49184
diff changeset
939
56824
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
940 .. impl-detail::
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
941
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
942 The :func:`settrace` function is intended only for implementing debuggers,
56824
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
943 profilers, coverage tools and the like. Its behavior is part of the
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
944 implementation platform, rather than part of the language definition, and
b7b8970cd5a5 Merged revisions 75363,75365,75376,75392,75394,75403,75418,75484,75572,75580,75590,75592,75594-75596,75600,75602-75603,75605-75607,75610-75613,75616-75617,75623,75627,75647 via svnmerge from
Georg Brandl <georg@python.org>
parents: 56820
diff changeset
945 thus may not be available in all Python implementations.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
946
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
947
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
948 .. function:: settscdump(on_flag)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
949
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
950 Activate dumping of VM measurements using the Pentium timestamp counter, if
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
951 *on_flag* is true. Deactivate these dumps if *on_flag* is off. The function is
66962
59e230297bff Merged revisions 86521,86632,86823-86824,87294,87296,87300,87302 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 66457
diff changeset
952 available only if Python was compiled with ``--with-tsc``. To understand
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
953 the output of this dump, read :file:`Python/ceval.c` in the Python sources.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
954
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
955 .. versionadded:: 2.4
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
956
61740
bf4e83de4ea5 Merged revisions 78717 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61094
diff changeset
957 .. impl-detail::
bf4e83de4ea5 Merged revisions 78717 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61094
diff changeset
958
bf4e83de4ea5 Merged revisions 78717 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61094
diff changeset
959 This function is intimately bound to CPython implementation details and
bf4e83de4ea5 Merged revisions 78717 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61094
diff changeset
960 thus not likely to be implemented elsewhere.
bf4e83de4ea5 Merged revisions 78717 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61094
diff changeset
961
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
962
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
963 .. data:: stdin
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
964 stdout
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
965 stderr
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
966
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
967 .. index::
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
968 builtin: input
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
969 builtin: raw_input
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
970
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
971 File objects corresponding to the interpreter's standard input, output and error
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
972 streams. ``stdin`` is used for all interpreter input except for scripts but
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
973 including calls to :func:`input` and :func:`raw_input`. ``stdout`` is used for
44103
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
974 the output of :keyword:`print` and :term:`expression` statements and for the
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
975 prompts of :func:`input` and :func:`raw_input`. The interpreter's own prompts
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
976 and (almost all of) its error messages go to ``stderr``. ``stdout`` and
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
977 ``stderr`` needn't be built-in file objects: any object is acceptable as long
50522
ee9ced92843a Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
Georg Brandl <georg@python.org>
parents: 50002
diff changeset
978 as it has a :meth:`write` method that takes a string argument. (Changing these
44103
1e266015cf5b Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents: 44089
diff changeset
979 objects doesn't affect the standard I/O streams of processes executed by
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
980 :func:`os.popen`, :func:`os.system` or the :func:`exec\*` family of functions in
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
981 the :mod:`os` module.)
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
982
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
983
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
984 .. data:: __stdin__
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
985 __stdout__
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
986 __stderr__
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
987
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
988 These objects contain the original values of ``stdin``, ``stderr`` and
52900
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
989 ``stdout`` at the start of the program. They are used during finalization,
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
990 and could be useful to print to the actual standard stream no matter if the
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
991 ``sys.std*`` object has been redirected.
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
992
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
993 It can also be used to restore the actual files to known working file objects
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
994 in case they have been overwritten with a broken object. However, the
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
995 preferred way to do this is to explicitly save the previous stream before
4acbbb3e65e2 Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from
Georg Brandl <georg@python.org>
parents: 52898
diff changeset
996 replacing it, and restore the saved object.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
997
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
998
71289
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
999 .. data:: subversion
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1000
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1001 A triple (repo, branch, version) representing the Subversion information of the
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1002 Python interpreter. *repo* is the name of the repository, ``'CPython'``.
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1003 *branch* is a string of one of the forms ``'trunk'``, ``'branches/name'`` or
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1004 ``'tags/name'``. *version* is the output of ``svnversion``, if the interpreter
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1005 was built from a Subversion checkout; it contains the revision number (range)
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1006 and possibly a trailing 'M' if there were local modifications. If the tree was
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1007 exported (or svnversion was not available), it is the revision of
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1008 ``Include/patchlevel.h`` if the branch is a tag. Otherwise, it is ``None``.
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1009
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1010 .. versionadded:: 2.5
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1011
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1012 .. note::
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1013 Python is now `developed <http://docs.python.org/devguide/>`_ using
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1014 Mercurial. In recent Python 2.7 bugfix releases, :data:`subversion`
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1015 therefore contains placeholder information. It is removed in Python
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1016 3.3.
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1017
e1660bc0fa5b Move sys.subversion at the right place in alphabetical order,
Antoine Pitrou <solipsis@pitrou.net>
parents: 71284
diff changeset
1018
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1019 .. data:: tracebacklimit
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1020
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1021 When this variable is set to an integer value, it determines the maximum number
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1022 of levels of traceback information printed when an unhandled exception occurs.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1023 The default is ``1000``. When set to ``0`` or less, all traceback information
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1024 is suppressed and only the exception type and value are printed.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1025
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1026
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1027 .. data:: version
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1028
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1029 A string containing the version number of the Python interpreter plus additional
63509
5fd09e410d36 Merged revisions 83429,83436 via svnmerge from
Georg Brandl <georg@python.org>
parents: 62718
diff changeset
1030 information on the build number and compiler used. This string is displayed
5fd09e410d36 Merged revisions 83429,83436 via svnmerge from
Georg Brandl <georg@python.org>
parents: 62718
diff changeset
1031 when the interactive interpreter is started. Do not extract version information
5fd09e410d36 Merged revisions 83429,83436 via svnmerge from
Georg Brandl <georg@python.org>
parents: 62718
diff changeset
1032 out of it, rather, use :data:`version_info` and the functions provided by the
5fd09e410d36 Merged revisions 83429,83436 via svnmerge from
Georg Brandl <georg@python.org>
parents: 62718
diff changeset
1033 :mod:`platform` module.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1034
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1035
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1036 .. data:: api_version
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1037
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1038 The C API version for this interpreter. Programmers may find this useful when
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1039 debugging version conflicts between Python and extension modules.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1040
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1041 .. versionadded:: 2.3
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1042
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1043
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1044 .. data:: version_info
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1045
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1046 A tuple containing the five components of the version number: *major*, *minor*,
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1047 *micro*, *releaselevel*, and *serial*. All values except *releaselevel* are
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1048 integers; the release level is ``'alpha'``, ``'beta'``, ``'candidate'``, or
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1049 ``'final'``. The ``version_info`` value corresponding to the Python version 2.0
51365
e239e977bb32 Implement issue #4285, convert sys.version_info to a named
Eric Smith <eric@trueblade.com>
parents: 50722
diff changeset
1050 is ``(2, 0, 0, 'final', 0)``. The components can also be accessed by name,
e239e977bb32 Implement issue #4285, convert sys.version_info to a named
Eric Smith <eric@trueblade.com>
parents: 50722
diff changeset
1051 so ``sys.version_info[0]`` is equivalent to ``sys.version_info.major``
e239e977bb32 Implement issue #4285, convert sys.version_info to a named
Eric Smith <eric@trueblade.com>
parents: 50722
diff changeset
1052 and so on.
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1053
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1054 .. versionadded:: 2.0
51365
e239e977bb32 Implement issue #4285, convert sys.version_info to a named
Eric Smith <eric@trueblade.com>
parents: 50722
diff changeset
1055 .. versionchanged:: 2.7
e239e977bb32 Implement issue #4285, convert sys.version_info to a named
Eric Smith <eric@trueblade.com>
parents: 50722
diff changeset
1056 Added named component attributes
42603
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1057
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1058
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1059 .. data:: warnoptions
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1060
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1061 This is an implementation detail of the warnings framework; do not modify this
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1062 value. Refer to the :mod:`warnings` module for more information on the warnings
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1063 framework.
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1064
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1065
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1066 .. data:: winver
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1067
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1068 The version number used to form registry keys on Windows platforms. This is
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1069 stored as string resource 1000 in the Python DLL. The value is normally the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1070 first three characters of :const:`version`. It is provided in the :mod:`sys`
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1071 module for informational purposes; modifying this value has no effect on the
c62f6669ae22 Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1072 registry keys used by Python. Availability: Windows.
62693
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
1073
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
1074 .. rubric:: Citations
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
1075
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
1076 .. [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 .
f1ba4e6d6c12 Merged revisions 82446 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 61740
diff changeset
1077