/
usr
/
share
/
doc
/
python2-docs
/
html
/
library
/
/usr/share/doc/python2-docs/html/library
mkdir
upload
Name
Size
Mode
Actions
2to3.html
59507
0644
edit
dl
rm
abc.html
25826
0644
edit
dl
rm
aepack.html
14164
0644
edit
dl
rm
aetools.html
16389
0644
edit
dl
rm
aetypes.html
21021
0644
edit
dl
rm
aifc.html
25064
0644
edit
dl
rm
al.html
18672
0644
edit
dl
rm
allos.html
35297
0644
edit
dl
rm
anydbm.html
18124
0644
edit
dl
rm
archiving.html
10078
0644
edit
dl
rm
argparse.html
263616
0644
edit
dl
rm
array.html
31855
0644
edit
dl
rm
ast.html
38167
0644
edit
dl
rm
asynchat.html
33930
0644
edit
dl
rm
asyncore.html
40631
0644
edit
dl
rm
atexit.html
18455
0644
edit
dl
rm
audioop.html
34252
0644
edit
dl
rm
autogil.html
8733
0644
edit
dl
rm
base64.html
21862
0644
edit
dl
rm
basehttpserver.html
37441
0644
edit
dl
rm
bastion.html
11798
0644
edit
dl
rm
bdb.html
41395
0644
edit
dl
rm
binascii.html
22997
0644
edit
dl
rm
binhex.html
11309
0644
edit
dl
rm
bisect.html
24666
0644
edit
dl
rm
bsddb.html
28589
0644
edit
dl
rm
bz2.html
29048
0644
edit
dl
rm
calendar.html
41762
0644
edit
dl
rm
carbon.html
51998
0644
edit
dl
rm
cd.html
30033
0644
edit
dl
rm
cgi.html
55922
0644
edit
dl
rm
cgihttpserver.html
14026
0644
edit
dl
rm
cgitb.html
12263
0644
edit
dl
rm
chunk.html
15899
0644
edit
dl
rm
cmath.html
28365
0644
edit
dl
rm
cmd.html
29042
0644
edit
dl
rm
code.html
26959
0644
edit
dl
rm
codecs.html
118258
0644
edit
dl
rm
codeop.html
15898
0644
edit
dl
rm
collections.html
147647
0644
edit
dl
rm
colorpicker.html
8035
0644
edit
dl
rm
colorsys.html
11919
0644
edit
dl
rm
commands.html
15516
0644
edit
dl
rm
compileall.html
18621
0644
edit
dl
rm
compiler.html
75897
0644
edit
dl
rm
configparser.html
67751
0644
edit
dl
rm
constants.html
13979
0644
edit
dl
rm
contextlib.html
22777
0644
edit
dl
rm
cookie.html
41854
0644
edit
dl
rm
cookielib.html
91032
0644
edit
dl
rm
copy.html
13004
0644
edit
dl
rm
copy_reg.html
14691
0644
edit
dl
rm
crypt.html
10647
0644
edit
dl
rm
crypto.html
7761
0644
edit
dl
rm
csv.html
76456
0644
edit
dl
rm
ctypes.html
264575
0644
edit
dl
rm
curses.ascii.html
24873
0644
edit
dl
rm
curses.html
167501
0644
edit
dl
rm
curses.panel.html
15824
0644
edit
dl
rm
custominterp.html
8026
0644
edit
dl
rm
datatypes.html
18015
0644
edit
dl
rm
datetime.html
253438
0644
edit
dl
rm
dbhash.html
16825
0644
edit
dl
rm
dbm.html
13507
0644
edit
dl
rm
debug.html
10703
0644
edit
dl
rm
decimal.html
222315
0644
edit
dl
rm
development.html
14828
0644
edit
dl
rm
difflib.html
91975
0644
edit
dl
rm
dircache.html
12299
0644
edit
dl
rm
dis.html
84156
0644
edit
dl
rm
distribution.html
7679
0644
edit
dl
rm
distutils.html
10152
0644
edit
dl
rm
dl.html
17668
0644
edit
dl
rm
doctest.html
185883
0644
edit
dl
rm
docxmlrpcserver.html
17573
0644
edit
dl
rm
dumbdbm.html
15549
0644
edit
dl
rm
dummy_thread.html
10065
0644
edit
dl
rm
dummy_threading.html
8934
0644
edit
dl
rm
easydialogs.html
33124
0644
edit
dl
rm
email-examples.html
47424
0644
edit
dl
rm
email.charset.html
29424
0644
edit
dl
rm
email.encoders.html
12847
0644
edit
dl
rm
email.errors.html
17952
0644
edit
dl
rm
email.generator.html
23141
0644
edit
dl
rm
email.header.html
29108
0644
edit
dl
rm
email.html
55722
0644
edit
dl
rm
email.iterators.html
12623
0644
edit
dl
rm
email.message.html
70189
0644
edit
dl
rm
email.mime.html
31655
0644
edit
dl
rm
email.parser.html
35142
0644
edit
dl
rm
email.utils.html
27076
0644
edit
dl
rm
ensurepip.html
18327
0644
edit
dl
rm
errno.html
40246
0644
edit
dl
rm
exceptions.html
63693
0644
edit
dl
rm
fcntl.html
26245
0644
edit
dl
rm
filecmp.html
23997
0644
edit
dl
rm
fileformats.html
9653
0644
edit
dl
rm
fileinput.html
27071
0644
edit
dl
rm
filesys.html
10866
0644
edit
dl
rm
fl.html
56525
0644
edit
dl
rm
fm.html
13009
0644
edit
dl
rm
fnmatch.html
16258
0644
edit
dl
rm
formatter.html
37371
0644
edit
dl
rm
fpectl.html
16879
0644
edit
dl
rm
fpformat.html
11455
0644
edit
dl
rm
fractions.html
24888
0644
edit
dl
rm
framework.html
36934
0644
edit
dl
rm
frameworks.html
7551
0644
edit
dl
rm
ftplib.html
49577
0644
edit
dl
rm
functions.html
205640
0644
edit
dl
rm
functools.html
29645
0644
edit
dl
rm
future_builtins.html
14477
0644
edit
dl
rm
gc.html
28423
0644
edit
dl
rm
gdbm.html
17805
0644
edit
dl
rm
gensuitemodule.html
12574
0644
edit
dl
rm
getopt.html
25280
0644
edit
dl
rm
getpass.html
11426
0644
edit
dl
rm
gettext.html
84971
0644
edit
dl
rm
gl.html
24342
0644
edit
dl
rm
glob.html
14430
0644
edit
dl
rm
grp.html
11316
0644
edit
dl
rm
gzip.html
20576
0644
edit
dl
rm
hashlib.html
25467
0644
edit
dl
rm
heapq.html
34890
0644
edit
dl
rm
hmac.html
14374
0644
edit
dl
rm
hotshot.html
20147
0644
edit
dl
rm
htmllib.html
27682
0644
edit
dl
rm
htmlparser.html
42433
0644
edit
dl
rm
httplib.html
70932
0644
edit
dl
rm
i18n.html
10047
0644
edit
dl
rm
ic.html
18654
0644
edit
dl
rm
idle.html
42148
0644
edit
dl
rm
imageop.html
16099
0644
edit
dl
rm
imaplib.html
58515
0644
edit
dl
rm
imgfile.html
12732
0644
edit
dl
rm
imghdr.html
12238
0644
edit
dl
rm
imp.html
37603
0644
edit
dl
rm
importlib.html
8926
0644
edit
dl
rm
imputil.html
33563
0644
edit
dl
rm
index.html
79088
0644
edit
dl
rm
inspect.html
56823
0644
edit
dl
rm
internet.html
26138
0644
edit
dl
rm
intro.html
9353
0644
edit
dl
rm
io.html
113701
0644
edit
dl
rm
ipc.html
16598
0644
edit
dl
rm
itertools.html
125397
0644
edit
dl
rm
jpeg.html
13757
0644
edit
dl
rm
json.html
73678
0644
edit
dl
rm
keyword.html
8210
0644
edit
dl
rm
language.html
11687
0644
edit
dl
rm
linecache.html
11416
0644
edit
dl
rm
locale.html
61576
0644
edit
dl
rm
logging.config.html
80045
0644
edit
dl
rm
logging.handlers.html
80194
0644
edit
dl
rm
logging.html
110254
0644
edit
dl
rm
mac.html
23376
0644
edit
dl
rm
macos.html
16129
0644
edit
dl
rm
macosa.html
14080
0644
edit
dl
rm
macostools.html
16898
0644
edit
dl
rm
macpath.html
8386
0644
edit
dl
rm
mailbox.html
171121
0644
edit
dl
rm
mailcap.html
14132
0644
edit
dl
rm
markup.html
19862
0644
edit
dl
rm
marshal.html
19456
0644
edit
dl
rm
math.html
44015
0644
edit
dl
rm
md5.html
15123
0644
edit
dl
rm
mhlib.html
24123
0644
edit
dl
rm
mimetools.html
21206
0644
edit
dl
rm
mimetypes.html
30634
0644
edit
dl
rm
mimewriter.html
16078
0644
edit
dl
rm
mimify.html
15279
0644
edit
dl
rm
miniaeframe.html
13109
0644
edit
dl
rm
misc.html
7236
0644
edit
dl
rm
mm.html
9570
0644
edit
dl
rm
mmap.html
30832
0644
edit
dl
rm
modulefinder.html
18096
0644
edit
dl
rm
modules.html
9017
0644
edit
dl
rm
msilib.html
57853
0644
edit
dl
rm
msvcrt.html
21232
0644
edit
dl
rm
multifile.html
26256
0644
edit
dl
rm
multiprocessing.html
414535
0644
edit
dl
rm
mutex.html
12147
0644
edit
dl
rm
netdata.html
18379
0644
edit
dl
rm
netrc.html
14021
0644
edit
dl
rm
new.html
13177
0644
edit
dl
rm
nis.html
11502
0644
edit
dl
rm
nntplib.html
45689
0644
edit
dl
rm
numbers.html
40636
0644
edit
dl
rm
numeric.html
14292
0644
edit
dl
rm
operator.html
93622
0644
edit
dl
rm
optparse.html
250109
0644
edit
dl
rm
os.html
240195
0644
edit
dl
rm
os.path.html
43402
0644
edit
dl
rm
ossaudiodev.html
45594
0644
edit
dl
rm
othergui.html
9403
0644
edit
dl
rm
parser.html
42558
0644
edit
dl
rm
pdb.html
38603
0644
edit
dl
rm
persistence.html
15676
0644
edit
dl
rm
pickle.html
109684
0644
edit
dl
rm
pickletools.html
11475
0644
edit
dl
rm
pipes.html
19685
0644
edit
dl
rm
pkgutil.html
27367
0644
edit
dl
rm
platform.html
31599
0644
edit
dl
rm
plistlib.html
18344
0644
edit
dl
rm
popen2.html
27601
0644
edit
dl
rm
poplib.html
24320
0644
edit
dl
rm
posix.html
16626
0644
edit
dl
rm
posixfile.html
21387
0644
edit
dl
rm
pprint.html
32207
0644
edit
dl
rm
profile.html
72788
0644
edit
dl
rm
pty.html
10195
0644
edit
dl
rm
pwd.html
12388
0644
edit
dl
rm
pyclbr.html
15812
0644
edit
dl
rm
pydoc.html
13650
0644
edit
dl
rm
pyexpat.html
80886
0644
edit
dl
rm
python.html
12854
0644
edit
dl
rm
py_compile.html
11932
0644
edit
dl
rm
queue.html
26856
0644
edit
dl
rm
quopri.html
12739
0644
edit
dl
rm
random.html
42722
0644
edit
dl
rm
re.html
155985
0644
edit
dl
rm
readline.html
37383
0644
edit
dl
rm
repr.html
21778
0644
edit
dl
rm
resource.html
28286
0644
edit
dl
rm
restricted.html
12366
0644
edit
dl
rm
rexec.html
40566
0644
edit
dl
rm
rfc822.html
46408
0644
edit
dl
rm
rlcompleter.html
14460
0644
edit
dl
rm
robotparser.html
13403
0644
edit
dl
rm
runpy.html
21925
0644
edit
dl
rm
sched.html
19878
0644
edit
dl
rm
scrolledtext.html
9728
0644
edit
dl
rm
select.html
44090
0644
edit
dl
rm
sets.html
40151
0644
edit
dl
rm
sgi.html
10371
0644
edit
dl
rm
sgmllib.html
34464
0644
edit
dl
rm
sha.html
13062
0644
edit
dl
rm
shelve.html
29955
0644
edit
dl
rm
shlex.html
35033
0644
edit
dl
rm
shutil.html
45454
0644
edit
dl
rm
signal.html
34023
0644
edit
dl
rm
simplehttpserver.html
20351
0644
edit
dl
rm
simplexmlrpcserver.html
37794
0644
edit
dl
rm
site.html
26887
0644
edit
dl
rm
smtpd.html
13587
0644
edit
dl
rm
smtplib.html
47054
0644
edit
dl
rm
sndhdr.html
10993
0644
edit
dl
rm
socket.html
116414
0644
edit
dl
rm
socketserver.html
76430
0644
edit
dl
rm
someos.html
16472
0644
edit
dl
rm
spwd.html
11163
0644
edit
dl
rm
sqlite3.html
150014
0644
edit
dl
rm
ssl.html
202453
0644
edit
dl
rm
stat.html
34597
0644
edit
dl
rm
statvfs.html
11326
0644
edit
dl
rm
stdtypes.html
298144
0644
edit
dl
rm
string.html
120219
0644
edit
dl
rm
stringio.html
20061
0644
edit
dl
rm
stringprep.html
17729
0644
edit
dl
rm
strings.html
15905
0644
edit
dl
rm
struct.html
44896
0644
edit
dl
rm
subprocess.html
110447
0644
edit
dl
rm
sun.html
7253
0644
edit
dl
rm
sunau.html
30011
0644
edit
dl
rm
sunaudio.html
19236
0644
edit
dl
rm
symbol.html
8140
0644
edit
dl
rm
symtable.html
25871
0644
edit
dl
rm
sys.html
110996
0644
edit
dl
rm
sysconfig.html
26299
0644
edit
dl
rm
syslog.html
19737
0644
edit
dl
rm
tabnanny.html
11393
0644
edit
dl
rm
tarfile.html
88728
0644
edit
dl
rm
telnetlib.html
27782
0644
edit
dl
rm
tempfile.html
31903
0644
edit
dl
rm
termios.html
17309
0644
edit
dl
rm
test.html
57030
0644
edit
dl
rm
textwrap.html
30135
0644
edit
dl
rm
thread.html
21486
0644
edit
dl
rm
threading.html
86655
0644
edit
dl
rm
time.html
63798
0644
edit
dl
rm
timeit.html
40529
0644
edit
dl
rm
tix.html
50582
0644
edit
dl
rm
tk.html
26568
0644
edit
dl
rm
tkinter.html
84316
0644
edit
dl
rm
token.html
20999
0644
edit
dl
rm
tokenize.html
20607
0644
edit
dl
rm
trace.html
28668
0644
edit
dl
rm
traceback.html
40900
0644
edit
dl
rm
ttk.html
108515
0644
edit
dl
rm
tty.html
9753
0644
edit
dl
rm
turtle.html
230483
0644
edit
dl
rm
types.html
29833
0644
edit
dl
rm
undoc.html
24680
0644
edit
dl
rm
unicodedata.html
20186
0644
edit
dl
rm
unittest.html
225021
0644
edit
dl
rm
unix.html
11223
0644
edit
dl
rm
urllib.html
68266
0644
edit
dl
rm
urllib2.html
113380
0644
edit
dl
rm
urlparse.html
43474
0644
edit
dl
rm
user.html
12707
0644
edit
dl
rm
userdict.html
32069
0644
edit
dl
rm
uu.html
11810
0644
edit
dl
rm
uuid.html
30137
0644
edit
dl
rm
warnings.html
50950
0644
edit
dl
rm
wave.html
24894
0644
edit
dl
rm
weakref.html
38808
0644
edit
dl
rm
webbrowser.html
26565
0644
edit
dl
rm
whichdb.html
9499
0644
edit
dl
rm
windows.html
9817
0644
edit
dl
rm
winsound.html
20466
0644
edit
dl
rm
wsgiref.html
88384
0644
edit
dl
rm
xdrlib.html
33018
0644
edit
dl
rm
xml.dom.html
97877
0644
edit
dl
rm
xml.dom.minidom.html
43230
0644
edit
dl
rm
xml.dom.pulldom.html
13835
0644
edit
dl
rm
xml.etree.elementtree.html
111804
0644
edit
dl
rm
xml.html
18007
0644
edit
dl
rm
xml.sax.handler.html
41877
0644
edit
dl
rm
xml.sax.html
23458
0644
edit
dl
rm
xml.sax.reader.html
44802
0644
edit
dl
rm
xml.sax.utils.html
16087
0644
edit
dl
rm
xmlrpclib.html
69191
0644
edit
dl
rm
zipfile.html
62227
0644
edit
dl
rm
zipimport.html
22769
0644
edit
dl
rm
zlib.html
31230
0644
edit
dl
rm
_winreg.html
64631
0644
edit
dl
rm
__builtin__.html
11069
0644
edit
dl
rm
__future__.html
14688
0644
edit
dl
rm
__main__.html
7512
0644
edit
dl
rm
Edit:
/usr/share/doc/python2-docs/html/library/sys.html
(110996B)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>28.1. sys — System-specific parameters and functions — Python 2.7.16 documentation</title> <link rel="stylesheet" href="../_static/classic.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.16 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="next" title="28.2. sysconfig — Provide access to Python’s configuration information" href="sysconfig.html" /> <link rel="prev" title="28. Python Runtime Services" href="python.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="https://docs.python.org/2/library/sys.html" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="sysconfig.html" title="28.2. sysconfig — Provide access to Python’s configuration information" accesskey="N">next</a> |</li> <li class="right" > <a href="python.html" title="28. Python Runtime Services" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.16 documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="python.html" accesskey="U">28. Python Runtime Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-sys"> <span id="sys-system-specific-parameters-and-functions"></span><h1>28.1. <a class="reference internal" href="#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> — System-specific parameters and functions<a class="headerlink" href="#module-sys" title="Permalink to this headline">¶</a></h1> <p>This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available.</p> <dl class="data"> <dt id="sys.argv"> <code class="descclassname">sys.</code><code class="descname">argv</code><a class="headerlink" href="#sys.argv" title="Permalink to this definition">¶</a></dt> <dd><p>The list of command line arguments passed to a Python script. <code class="docutils literal notranslate"><span class="pre">argv[0]</span></code> is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the <a class="reference internal" href="../using/cmdline.html#cmdoption-c"><code class="xref std std-option docutils literal notranslate"><span class="pre">-c</span></code></a> command line option to the interpreter, <code class="docutils literal notranslate"><span class="pre">argv[0]</span></code> is set to the string <code class="docutils literal notranslate"><span class="pre">'-c'</span></code>. If no script name was passed to the Python interpreter, <code class="docutils literal notranslate"><span class="pre">argv[0]</span></code> is the empty string.</p> <p>To loop over the standard input, or the list of files given on the command line, see the <a class="reference internal" href="fileinput.html#module-fileinput" title="fileinput: Loop over standard input or a list of files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">fileinput</span></code></a> module.</p> </dd></dl> <dl class="data"> <dt id="sys.byteorder"> <code class="descclassname">sys.</code><code class="descname">byteorder</code><a class="headerlink" href="#sys.byteorder" title="Permalink to this definition">¶</a></dt> <dd><p>An indicator of the native byte order. This will have the value <code class="docutils literal notranslate"><span class="pre">'big'</span></code> on big-endian (most-significant byte first) platforms, and <code class="docutils literal notranslate"><span class="pre">'little'</span></code> on little-endian (least-significant byte first) platforms.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.0.</span></p> </div> </dd></dl> <dl class="data"> <dt id="sys.builtin_module_names"> <code class="descclassname">sys.</code><code class="descname">builtin_module_names</code><a class="headerlink" href="#sys.builtin_module_names" title="Permalink to this definition">¶</a></dt> <dd><p>A tuple of strings giving the names of all modules that are compiled into this Python interpreter. (This information is not available in any other way — <code class="docutils literal notranslate"><span class="pre">modules.keys()</span></code> only lists the imported modules.)</p> </dd></dl> <dl class="function"> <dt id="sys.call_tracing"> <code class="descclassname">sys.</code><code class="descname">call_tracing</code><span class="sig-paren">(</span><em>func</em>, <em>args</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.call_tracing" title="Permalink to this definition">¶</a></dt> <dd><p>Call <code class="docutils literal notranslate"><span class="pre">func(*args)</span></code>, while tracing is enabled. The tracing state is saved, and restored afterwards. This is intended to be called from a debugger from a checkpoint, to recursively debug some other code.</p> </dd></dl> <dl class="data"> <dt id="sys.copyright"> <code class="descclassname">sys.</code><code class="descname">copyright</code><a class="headerlink" href="#sys.copyright" title="Permalink to this definition">¶</a></dt> <dd><p>A string containing the copyright pertaining to the Python interpreter.</p> </dd></dl> <dl class="function"> <dt id="sys._clear_type_cache"> <code class="descclassname">sys.</code><code class="descname">_clear_type_cache</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._clear_type_cache" title="Permalink to this definition">¶</a></dt> <dd><p>Clear the internal type cache. The type cache is used to speed up attribute and method lookups. Use the function <em>only</em> to drop unnecessary references during reference leak debugging.</p> <p>This function should be used for internal and specialized purposes only.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys._current_frames"> <code class="descclassname">sys.</code><code class="descname">_current_frames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._current_frames" title="Permalink to this definition">¶</a></dt> <dd><p>Return a dictionary mapping each thread’s identifier to the topmost stack frame currently active in that thread at the time the function is called. Note that functions in the <a class="reference internal" href="traceback.html#module-traceback" title="traceback: Print or retrieve a stack traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">traceback</span></code></a> module can build the call stack given such a frame.</p> <p>This is most useful for debugging deadlock: this function does not require the deadlocked threads’ cooperation, and such threads’ call stacks are frozen for as long as they remain deadlocked. The frame returned for a non-deadlocked thread may bear no relationship to that thread’s current activity by the time calling code examines the frame.</p> <p>This function should be used for internal and specialized purposes only.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.5.</span></p> </div> </dd></dl> <dl class="data"> <dt id="sys.dllhandle"> <code class="descclassname">sys.</code><code class="descname">dllhandle</code><a class="headerlink" href="#sys.dllhandle" title="Permalink to this definition">¶</a></dt> <dd><p>Integer specifying the handle of the Python DLL. Availability: Windows.</p> </dd></dl> <dl class="function"> <dt id="sys.displayhook"> <code class="descclassname">sys.</code><code class="descname">displayhook</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.displayhook" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>value</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, this function prints it to <code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code>, and saves it in <code class="docutils literal notranslate"><span class="pre">__builtin__._</span></code>.</p> <p><code class="docutils literal notranslate"><span class="pre">sys.displayhook</span></code> is called on the result of evaluating an <a class="reference internal" href="../glossary.html#term-expression"><span class="xref std std-term">expression</span></a> entered in an interactive Python session. The display of these values can be customized by assigning another one-argument function to <code class="docutils literal notranslate"><span class="pre">sys.displayhook</span></code>.</p> </dd></dl> <dl class="data"> <dt id="sys.dont_write_bytecode"> <code class="descclassname">sys.</code><code class="descname">dont_write_bytecode</code><a class="headerlink" href="#sys.dont_write_bytecode" title="Permalink to this definition">¶</a></dt> <dd><p>If this is true, Python won’t try to write <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> or <code class="docutils literal notranslate"><span class="pre">.pyo</span></code> files on the import of source modules. This value is initially set to <code class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code> depending on the <a class="reference internal" href="../using/cmdline.html#id1"><code class="xref std std-option docutils literal notranslate"><span class="pre">-B</span></code></a> command line option and the <span class="target" id="index-0"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDONTWRITEBYTECODE</span></code></a> environment variable, but you can set it yourself to control bytecode file generation.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.excepthook"> <code class="descclassname">sys.</code><code class="descname">excepthook</code><span class="sig-paren">(</span><em>type</em>, <em>value</em>, <em>traceback</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.excepthook" title="Permalink to this definition">¶</a></dt> <dd><p>This function prints out a given traceback and exception to <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code>.</p> <p>When an exception is raised and uncaught, the interpreter calls <code class="docutils literal notranslate"><span class="pre">sys.excepthook</span></code> with three arguments, the exception class, exception instance, and a traceback object. In an interactive session this happens just before control is returned to the prompt; in a Python program this happens just before the program exits. The handling of such top-level exceptions can be customized by assigning another three-argument function to <code class="docutils literal notranslate"><span class="pre">sys.excepthook</span></code>.</p> </dd></dl> <dl class="data"> <dt id="sys.__displayhook__"> <code class="descclassname">sys.</code><code class="descname">__displayhook__</code><a class="headerlink" href="#sys.__displayhook__" title="Permalink to this definition">¶</a></dt> <dt id="sys.__excepthook__"> <code class="descclassname">sys.</code><code class="descname">__excepthook__</code><a class="headerlink" href="#sys.__excepthook__" title="Permalink to this definition">¶</a></dt> <dd><p>These objects contain the original values of <code class="docutils literal notranslate"><span class="pre">displayhook</span></code> and <code class="docutils literal notranslate"><span class="pre">excepthook</span></code> at the start of the program. They are saved so that <code class="docutils literal notranslate"><span class="pre">displayhook</span></code> and <code class="docutils literal notranslate"><span class="pre">excepthook</span></code> can be restored in case they happen to get replaced with broken objects.</p> </dd></dl> <dl class="function"> <dt id="sys.exc_info"> <code class="descclassname">sys.</code><code class="descname">exc_info</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.exc_info" title="Permalink to this definition">¶</a></dt> <dd><p>This function returns a tuple of three values that give information about the exception that is currently being handled. The information returned is specific both to the current thread and to the current stack frame. If the current stack frame is not handling an exception, the information is taken from the calling stack frame, or its caller, and so on until a stack frame is found that is handling an exception. Here, “handling an exception” is defined as “executing or having executed an except clause.” For any stack frame, only information about the most recently handled exception is accessible.</p> <p id="index-1">If no exception is being handled anywhere on the stack, a tuple containing three <code class="docutils literal notranslate"><span class="pre">None</span></code> values is returned. Otherwise, the values returned are <code class="docutils literal notranslate"><span class="pre">(type,</span> <span class="pre">value,</span> <span class="pre">traceback)</span></code>. Their meaning is: <em>type</em> gets the exception type of the exception being handled (a class object); <em>value</em> gets the exception parameter (its <em class="dfn">associated value</em> or the second argument to <a class="reference internal" href="../reference/simple_stmts.html#raise"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">raise</span></code></a>, which is always a class instance if the exception type is a class object); <em>traceback</em> gets a traceback object (see the Reference Manual) which encapsulates the call stack at the point where the exception originally occurred.</p> <p>If <a class="reference internal" href="#sys.exc_clear" title="sys.exc_clear"><code class="xref py py-func docutils literal notranslate"><span class="pre">exc_clear()</span></code></a> is called, this function will return three <code class="docutils literal notranslate"><span class="pre">None</span></code> values until either another exception is raised in the current thread or the execution stack returns to a frame where another exception is being handled.</p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Assigning the <em>traceback</em> return value to a local variable in a function that is handling an exception will cause a circular reference. This will prevent anything referenced by a local variable in the same function or by the traceback from being garbage collected. Since most functions don’t need access to the traceback, the best solution is to use something like <code class="docutils literal notranslate"><span class="pre">exctype,</span> <span class="pre">value</span> <span class="pre">=</span> <span class="pre">sys.exc_info()[:2]</span></code> to extract only the exception type and value. If you do need the traceback, make sure to delete it after use (best done with a <a class="reference internal" href="../reference/compound_stmts.html#try"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> … <a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a> statement) or to call <a class="reference internal" href="#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">exc_info()</span></code></a> in a function that does not itself handle an exception.</p> </div> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Beginning with Python 2.2, such cycles are automatically reclaimed when garbage collection is enabled and they become unreachable, but it remains more efficient to avoid creating cycles.</p> </div> </dd></dl> <dl class="function"> <dt id="sys.exc_clear"> <code class="descclassname">sys.</code><code class="descname">exc_clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.exc_clear" title="Permalink to this definition">¶</a></dt> <dd><p>This function clears all information relating to the current or last exception that occurred in the current thread. After calling this function, <a class="reference internal" href="#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">exc_info()</span></code></a> will return three <code class="docutils literal notranslate"><span class="pre">None</span></code> values until another exception is raised in the current thread or the execution stack returns to a frame where another exception is being handled.</p> <p>This function is only needed in only a few obscure situations. These include logging and error handling systems that report information on the last or current exception. This function can also be used to try to free resources and trigger object finalization, though no guarantee is made as to what objects will be freed, if any.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.3.</span></p> </div> </dd></dl> <dl class="data"> <dt id="sys.exc_type"> <code class="descclassname">sys.</code><code class="descname">exc_type</code><a class="headerlink" href="#sys.exc_type" title="Permalink to this definition">¶</a></dt> <dt id="sys.exc_value"> <code class="descclassname">sys.</code><code class="descname">exc_value</code><a class="headerlink" href="#sys.exc_value" title="Permalink to this definition">¶</a></dt> <dt id="sys.exc_traceback"> <code class="descclassname">sys.</code><code class="descname">exc_traceback</code><a class="headerlink" href="#sys.exc_traceback" title="Permalink to this definition">¶</a></dt> <dd><div class="deprecated"> <p><span class="versionmodified">Deprecated since version 1.5: </span>Use <a class="reference internal" href="#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">exc_info()</span></code></a> instead.</p> </div> <p>Since they are global variables, they are not specific to the current thread, so their use is not safe in a multi-threaded program. When no exception is being handled, <code class="docutils literal notranslate"><span class="pre">exc_type</span></code> is set to <code class="docutils literal notranslate"><span class="pre">None</span></code> and the other two are undefined.</p> </dd></dl> <dl class="data"> <dt id="sys.exec_prefix"> <code class="descclassname">sys.</code><code class="descname">exec_prefix</code><a class="headerlink" href="#sys.exec_prefix" title="Permalink to this definition">¶</a></dt> <dd><p>A string giving the site-specific directory prefix where the platform-dependent Python files are installed; by default, this is also <code class="docutils literal notranslate"><span class="pre">'/usr/local'</span></code>. This can be set at build time with the <code class="docutils literal notranslate"><span class="pre">--exec-prefix</span></code> argument to the <strong class="program">configure</strong> script. Specifically, all configuration files (e.g. the <code class="file docutils literal notranslate"><span class="pre">pyconfig.h</span></code> header file) are installed in the directory <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">X.Y</span></em><span class="pre">/config</span></code>, and shared library modules are installed in <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">X.Y</span></em><span class="pre">/lib-dynload</span></code>, where <em>X.Y</em> is the version number of Python, for example <code class="docutils literal notranslate"><span class="pre">2.7</span></code>.</p> </dd></dl> <dl class="data"> <dt id="sys.executable"> <code class="descclassname">sys.</code><code class="descname">executable</code><a class="headerlink" href="#sys.executable" title="Permalink to this definition">¶</a></dt> <dd><p>A string giving the absolute path of the executable binary for the Python interpreter, on systems where this makes sense. If Python is unable to retrieve the real path to its executable, <a class="reference internal" href="#sys.executable" title="sys.executable"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.executable</span></code></a> will be an empty string or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> </dd></dl> <dl class="function"> <dt id="sys.exit"> <code class="descclassname">sys.</code><code class="descname">exit</code><span class="sig-paren">(</span><span class="optional">[</span><em>arg</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.exit" title="Permalink to this definition">¶</a></dt> <dd><p>Exit from Python. This is implemented by raising the <a class="reference internal" href="exceptions.html#exceptions.SystemExit" title="exceptions.SystemExit"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemExit</span></code></a> exception, so cleanup actions specified by finally clauses of <a class="reference internal" href="../reference/compound_stmts.html#try"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> statements are honored, and it is possible to intercept the exit attempt at an outer level.</p> <p>The optional argument <em>arg</em> can be an integer giving the exit status (defaulting to zero), or another type of object. If it is an integer, zero is considered “successful termination” and any nonzero value is considered “abnormal termination” by shells and the like. Most systems require it to be in the range 0–127, and produce undefined results otherwise. Some systems have a convention for assigning specific meanings to specific exit codes, but these are generally underdeveloped; Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors. If another type of object is passed, <code class="docutils literal notranslate"><span class="pre">None</span></code> is equivalent to passing zero, and any other object is printed to <a class="reference internal" href="#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">stderr</span></code></a> and results in an exit code of 1. In particular, <code class="docutils literal notranslate"><span class="pre">sys.exit("some</span> <span class="pre">error</span> <span class="pre">message")</span></code> is a quick way to exit a program when an error occurs.</p> <p>Since <a class="reference internal" href="constants.html#exit" title="exit"><code class="xref py py-func docutils literal notranslate"><span class="pre">exit()</span></code></a> ultimately “only” raises an exception, it will only exit the process when called from the main thread, and the exception is not intercepted.</p> </dd></dl> <dl class="data"> <dt id="sys.exitfunc"> <code class="descclassname">sys.</code><code class="descname">exitfunc</code><a class="headerlink" href="#sys.exitfunc" title="Permalink to this definition">¶</a></dt> <dd><p>This value is not actually defined by the module, but can be set by the user (or by a program) to specify a clean-up action at program exit. When set, it should be a parameterless function. This function will be called when the interpreter exits. Only one function may be installed in this way; to allow multiple functions which will be called at termination, use the <a class="reference internal" href="atexit.html#module-atexit" title="atexit: Register and execute cleanup functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">atexit</span></code></a> module.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">The exit function is not called when the program is killed by a signal, when a Python fatal internal error is detected, or when <code class="docutils literal notranslate"><span class="pre">os._exit()</span></code> is called.</p> </div> <div class="deprecated"> <p><span class="versionmodified">Deprecated since version 2.4: </span>Use <a class="reference internal" href="atexit.html#module-atexit" title="atexit: Register and execute cleanup functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">atexit</span></code></a> instead.</p> </div> </dd></dl> <dl class="data"> <dt id="sys.flags"> <code class="descclassname">sys.</code><code class="descname">flags</code><a class="headerlink" href="#sys.flags" title="Permalink to this definition">¶</a></dt> <dd><p>The struct sequence <em>flags</em> exposes the status of command line flags. The attributes are read only.</p> <table border="1" class="docutils"> <colgroup> <col width="45%" /> <col width="55%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">attribute</th> <th class="head">flag</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">debug</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-d"><code class="xref std std-option docutils literal notranslate"><span class="pre">-d</span></code></a></td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">py3k_warning</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-3"><code class="xref std std-option docutils literal notranslate"><span class="pre">-3</span></code></a></td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">division_warning</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-q"><code class="xref std std-option docutils literal notranslate"><span class="pre">-Q</span></code></a></td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">division_new</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-q"><code class="xref std std-option docutils literal notranslate"><span class="pre">-Qnew</span></code></a></td> </tr> <tr class="row-even"><td><a class="reference internal" href="inspect.html#module-inspect" title="inspect: Extract information and source code from live objects."><code class="xref py py-const docutils literal notranslate"><span class="pre">inspect</span></code></a></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a></td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">interactive</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a></td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">optimize</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-o"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> or <a class="reference internal" href="../using/cmdline.html#cmdoption-oo"><code class="xref std std-option docutils literal notranslate"><span class="pre">-OO</span></code></a></td> </tr> <tr class="row-odd"><td><a class="reference internal" href="#sys.dont_write_bytecode" title="sys.dont_write_bytecode"><code class="xref py py-const docutils literal notranslate"><span class="pre">dont_write_bytecode</span></code></a></td> <td><a class="reference internal" href="../using/cmdline.html#id1"><code class="xref std std-option docutils literal notranslate"><span class="pre">-B</span></code></a></td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">no_user_site</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-s"><code class="xref std std-option docutils literal notranslate"><span class="pre">-s</span></code></a></td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">no_site</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#id2"><code class="xref std std-option docutils literal notranslate"><span class="pre">-S</span></code></a></td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">ignore_environment</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-e"><code class="xref std std-option docutils literal notranslate"><span class="pre">-E</span></code></a></td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">tabcheck</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-t"><code class="xref std std-option docutils literal notranslate"><span class="pre">-t</span></code></a> or <a class="reference internal" href="../using/cmdline.html#cmdoption-t"><code class="xref std std-option docutils literal notranslate"><span class="pre">-tt</span></code></a></td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">verbose</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#id3"><code class="xref std std-option docutils literal notranslate"><span class="pre">-v</span></code></a></td> </tr> <tr class="row-odd"><td><a class="reference internal" href="functions.html#unicode" title="unicode"><code class="xref py py-const docutils literal notranslate"><span class="pre">unicode</span></code></a></td> <td><a class="reference internal" href="../using/cmdline.html#id4"><code class="xref std std-option docutils literal notranslate"><span class="pre">-U</span></code></a></td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">bytes_warning</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-b"><code class="xref std std-option docutils literal notranslate"><span class="pre">-b</span></code></a></td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">hash_randomization</span></code></td> <td><a class="reference internal" href="../using/cmdline.html#cmdoption-r"><code class="xref std std-option docutils literal notranslate"><span class="pre">-R</span></code></a></td> </tr> </tbody> </table> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.3: </span>The <code class="docutils literal notranslate"><span class="pre">hash_randomization</span></code> attribute.</p> </div> </dd></dl> <dl class="data"> <dt id="sys.float_info"> <code class="descclassname">sys.</code><code class="descname">float_info</code><a class="headerlink" href="#sys.float_info" title="Permalink to this definition">¶</a></dt> <dd><p>A structseq holding information about the float type. It contains low level information about the precision and internal representation. The values correspond to the various floating-point constants defined in the standard header file <code class="file docutils literal notranslate"><span class="pre">float.h</span></code> for the ‘C’ programming language; see section 5.2.4.2.2 of the 1999 ISO/IEC C standard <a class="reference internal" href="#c99" id="id1">[C99]</a>, ‘Characteristics of floating types’, for details.</p> <table border="1" class="docutils"> <colgroup> <col width="24%" /> <col width="18%" /> <col width="57%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">attribute</th> <th class="head">float.h macro</th> <th class="head">explanation</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">epsilon</span></code></td> <td>DBL_EPSILON</td> <td>difference between 1 and the least value greater than 1 that is representable as a float</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">dig</span></code></td> <td>DBL_DIG</td> <td>maximum number of decimal digits that can be faithfully represented in a float; see below</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">mant_dig</span></code></td> <td>DBL_MANT_DIG</td> <td>float precision: the number of base-<code class="docutils literal notranslate"><span class="pre">radix</span></code> digits in the significand of a float</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="functions.html#max" title="max"><code class="xref py py-const docutils literal notranslate"><span class="pre">max</span></code></a></td> <td>DBL_MAX</td> <td>maximum representable finite float</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">max_exp</span></code></td> <td>DBL_MAX_EXP</td> <td>maximum integer e such that <code class="docutils literal notranslate"><span class="pre">radix**(e-1)</span></code> is a representable finite float</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">max_10_exp</span></code></td> <td>DBL_MAX_10_EXP</td> <td>maximum integer e such that <code class="docutils literal notranslate"><span class="pre">10**e</span></code> is in the range of representable finite floats</td> </tr> <tr class="row-even"><td><a class="reference internal" href="functions.html#min" title="min"><code class="xref py py-const docutils literal notranslate"><span class="pre">min</span></code></a></td> <td>DBL_MIN</td> <td>minimum positive normalized float</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">min_exp</span></code></td> <td>DBL_MIN_EXP</td> <td>minimum integer e such that <code class="docutils literal notranslate"><span class="pre">radix**(e-1)</span></code> is a normalized float</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">min_10_exp</span></code></td> <td>DBL_MIN_10_EXP</td> <td>minimum integer e such that <code class="docutils literal notranslate"><span class="pre">10**e</span></code> is a normalized float</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">radix</span></code></td> <td>FLT_RADIX</td> <td>radix of exponent representation</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">rounds</span></code></td> <td>FLT_ROUNDS</td> <td>integer constant representing the rounding mode used for arithmetic operations. This reflects the value of the system FLT_ROUNDS macro at interpreter startup time. See section 5.2.4.2.2 of the C99 standard for an explanation of the possible values and their meanings.</td> </tr> </tbody> </table> <p>The attribute <code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.float_info.dig</span></code> needs further explanation. If <code class="docutils literal notranslate"><span class="pre">s</span></code> is any string representing a decimal number with at most <code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.float_info.dig</span></code> significant digits, then converting <code class="docutils literal notranslate"><span class="pre">s</span></code> to a float and back again will recover a string representing the same decimal value:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">sys</span> <span class="gp">>>> </span><span class="n">sys</span><span class="o">.</span><span class="n">float_info</span><span class="o">.</span><span class="n">dig</span> <span class="go">15</span> <span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="s1">'3.14159265358979'</span> <span class="c1"># decimal string with 15 significant digits</span> <span class="gp">>>> </span><span class="nb">format</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">s</span><span class="p">),</span> <span class="s1">'.15g'</span><span class="p">)</span> <span class="c1"># convert to float and back -> same value</span> <span class="go">'3.14159265358979'</span> </pre></div> </div> <p>But for strings with more than <code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.float_info.dig</span></code> significant digits, this isn’t always true:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="s1">'9876543211234567'</span> <span class="c1"># 16 significant digits is too many!</span> <span class="gp">>>> </span><span class="nb">format</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">s</span><span class="p">),</span> <span class="s1">'.16g'</span><span class="p">)</span> <span class="c1"># conversion changes value</span> <span class="go">'9876543211234568'</span> </pre></div> </div> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="data"> <dt id="sys.float_repr_style"> <code class="descclassname">sys.</code><code class="descname">float_repr_style</code><a class="headerlink" href="#sys.float_repr_style" title="Permalink to this definition">¶</a></dt> <dd><p>A string indicating how the <a class="reference internal" href="functions.html#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a> function behaves for floats. If the string has value <code class="docutils literal notranslate"><span class="pre">'short'</span></code> then for a finite float <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">repr(x)</span></code> aims to produce a short string with the property that <code class="docutils literal notranslate"><span class="pre">float(repr(x))</span> <span class="pre">==</span> <span class="pre">x</span></code>. This is the usual behaviour in Python 2.7 and later. Otherwise, <code class="docutils literal notranslate"><span class="pre">float_repr_style</span></code> has value <code class="docutils literal notranslate"><span class="pre">'legacy'</span></code> and <code class="docutils literal notranslate"><span class="pre">repr(x)</span></code> behaves in the same way as it did in versions of Python prior to 2.7.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.getcheckinterval"> <code class="descclassname">sys.</code><code class="descname">getcheckinterval</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getcheckinterval" title="Permalink to this definition">¶</a></dt> <dd><p>Return the interpreter’s “check interval”; see <a class="reference internal" href="#sys.setcheckinterval" title="sys.setcheckinterval"><code class="xref py py-func docutils literal notranslate"><span class="pre">setcheckinterval()</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.getdefaultencoding"> <code class="descclassname">sys.</code><code class="descname">getdefaultencoding</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getdefaultencoding" title="Permalink to this definition">¶</a></dt> <dd><p>Return the name of the current default string encoding used by the Unicode implementation.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.0.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.getdlopenflags"> <code class="descclassname">sys.</code><code class="descname">getdlopenflags</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getdlopenflags" title="Permalink to this definition">¶</a></dt> <dd><p>Return the current value of the flags that are used for <code class="xref c c-func docutils literal notranslate"><span class="pre">dlopen()</span></code> calls. The flag constants are defined in the <a class="reference internal" href="dl.html#module-dl" title="dl: Call C functions in shared objects. (deprecated) (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dl</span></code></a> and <code class="xref py py-mod docutils literal notranslate"><span class="pre">DLFCN</span></code> modules. Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.2.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.getfilesystemencoding"> <code class="descclassname">sys.</code><code class="descname">getfilesystemencoding</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getfilesystemencoding" title="Permalink to this definition">¶</a></dt> <dd><p>Return the name of the encoding used to convert Unicode filenames into system file names, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the system default encoding is used. The result value depends on the operating system:</p> <ul class="simple"> <li>On Mac OS X, the encoding is <code class="docutils literal notranslate"><span class="pre">'utf-8'</span></code>.</li> <li>On Unix, the encoding is the user’s preference according to the result of nl_langinfo(CODESET), or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the <code class="docutils literal notranslate"><span class="pre">nl_langinfo(CODESET)</span></code> failed.</li> <li>On Windows NT+, file names are Unicode natively, so no conversion is performed. <a class="reference internal" href="#sys.getfilesystemencoding" title="sys.getfilesystemencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">getfilesystemencoding()</span></code></a> still returns <code class="docutils literal notranslate"><span class="pre">'mbcs'</span></code>, as this is the encoding that applications should use when they explicitly want to convert Unicode strings to byte strings that are equivalent when used as file names.</li> <li>On Windows 9x, the encoding is <code class="docutils literal notranslate"><span class="pre">'mbcs'</span></code>.</li> </ul> <div class="versionadded"> <p><span class="versionmodified">New in version 2.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.getrefcount"> <code class="descclassname">sys.</code><code class="descname">getrefcount</code><span class="sig-paren">(</span><em>object</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.getrefcount" title="Permalink to this definition">¶</a></dt> <dd><p>Return the reference count of the <em>object</em>. The count returned is generally one higher than you might expect, because it includes the (temporary) reference as an argument to <a class="reference internal" href="#sys.getrefcount" title="sys.getrefcount"><code class="xref py py-func docutils literal notranslate"><span class="pre">getrefcount()</span></code></a>.</p> </dd></dl> <dl class="function"> <dt id="sys.getrecursionlimit"> <code class="descclassname">sys.</code><code class="descname">getrecursionlimit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getrecursionlimit" title="Permalink to this definition">¶</a></dt> <dd><p>Return the current value of the recursion limit, the maximum depth of the Python interpreter stack. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python. It can be set by <a class="reference internal" href="#sys.setrecursionlimit" title="sys.setrecursionlimit"><code class="xref py py-func docutils literal notranslate"><span class="pre">setrecursionlimit()</span></code></a>.</p> </dd></dl> <dl class="function"> <dt id="sys.getsizeof"> <code class="descclassname">sys.</code><code class="descname">getsizeof</code><span class="sig-paren">(</span><em>object</em><span class="optional">[</span>, <em>default</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getsizeof" title="Permalink to this definition">¶</a></dt> <dd><p>Return the size of an object in bytes. The object can be any type of object. All built-in objects will return correct results, but this does not have to hold true for third-party extensions as it is implementation specific.</p> <p>If given, <em>default</em> will be returned if the object does not provide means to retrieve the size. Otherwise a <a class="reference internal" href="exceptions.html#exceptions.TypeError" title="exceptions.TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> will be raised.</p> <p><a class="reference internal" href="#sys.getsizeof" title="sys.getsizeof"><code class="xref py py-func docutils literal notranslate"><span class="pre">getsizeof()</span></code></a> calls the object’s <code class="docutils literal notranslate"><span class="pre">__sizeof__</span></code> method and adds an additional garbage collector overhead if the object is managed by the garbage collector.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys._getframe"> <code class="descclassname">sys.</code><code class="descname">_getframe</code><span class="sig-paren">(</span><span class="optional">[</span><em>depth</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._getframe" title="Permalink to this definition">¶</a></dt> <dd><p>Return a frame object from the call stack. If optional integer <em>depth</em> is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, <a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised. The default for <em>depth</em> is zero, returning the frame at the top of the call stack.</p> <div class="impl-detail compound"> <p><strong>CPython implementation detail:</strong> This function should be used for internal and specialized purposes only. It is not guaranteed to exist in all implementations of Python.</p> </div> </dd></dl> <dl class="function"> <dt id="sys.getprofile"> <code class="descclassname">sys.</code><code class="descname">getprofile</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getprofile" title="Permalink to this definition">¶</a></dt> <dd><p id="index-2">Get the profiler function as set by <a class="reference internal" href="#sys.setprofile" title="sys.setprofile"><code class="xref py py-func docutils literal notranslate"><span class="pre">setprofile()</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.gettrace"> <code class="descclassname">sys.</code><code class="descname">gettrace</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.gettrace" title="Permalink to this definition">¶</a></dt> <dd><p id="index-3">Get the trace function as set by <a class="reference internal" href="#sys.settrace" title="sys.settrace"><code class="xref py py-func docutils literal notranslate"><span class="pre">settrace()</span></code></a>.</p> <div class="impl-detail compound"> <p><strong>CPython implementation detail:</strong> The <a class="reference internal" href="#sys.gettrace" title="sys.gettrace"><code class="xref py py-func docutils literal notranslate"><span class="pre">gettrace()</span></code></a> function is intended only for implementing debuggers, profilers, coverage tools and the like. Its behavior is part of the implementation platform, rather than part of the language definition, and thus may not be available in all Python implementations.</p> </div> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.getwindowsversion"> <code class="descclassname">sys.</code><code class="descname">getwindowsversion</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getwindowsversion" title="Permalink to this definition">¶</a></dt> <dd><p>Return a named tuple describing the Windows version currently running. The named elements are <em>major</em>, <em>minor</em>, <em>build</em>, <em>platform</em>, <em>service_pack</em>, <em>service_pack_minor</em>, <em>service_pack_major</em>, <em>suite_mask</em>, and <em>product_type</em>. <em>service_pack</em> contains a string while all other values are integers. The components can also be accessed by name, so <code class="docutils literal notranslate"><span class="pre">sys.getwindowsversion()[0]</span></code> is equivalent to <code class="docutils literal notranslate"><span class="pre">sys.getwindowsversion().major</span></code>. For compatibility with prior versions, only the first 5 elements are retrievable by indexing.</p> <p><em>platform</em> may be one of the following values:</p> <table border="1" class="docutils"> <colgroup> <col width="62%" /> <col width="38%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Constant</th> <th class="head">Platform</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">0</span> <span class="pre">(VER_PLATFORM_WIN32s)</span></code></td> <td>Win32s on Windows 3.1</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">1</span> <span class="pre">(VER_PLATFORM_WIN32_WINDOWS)</span></code></td> <td>Windows 95/98/ME</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">2</span> <span class="pre">(VER_PLATFORM_WIN32_NT)</span></code></td> <td>Windows NT/2000/XP/x64</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">3</span> <span class="pre">(VER_PLATFORM_WIN32_CE)</span></code></td> <td>Windows CE</td> </tr> </tbody> </table> <p><em>product_type</em> may be one of the following values:</p> <table border="1" class="docutils"> <colgroup> <col width="54%" /> <col width="46%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Constant</th> <th class="head">Meaning</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">1</span> <span class="pre">(VER_NT_WORKSTATION)</span></code></td> <td>The system is a workstation.</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">2</span> <span class="pre">(VER_NT_DOMAIN_CONTROLLER)</span></code></td> <td>The system is a domain controller.</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">3</span> <span class="pre">(VER_NT_SERVER)</span></code></td> <td>The system is a server, but not a domain controller.</td> </tr> </tbody> </table> <p>This function wraps the Win32 <code class="xref c c-func docutils literal notranslate"><span class="pre">GetVersionEx()</span></code> function; see the Microsoft documentation on <code class="xref c c-func docutils literal notranslate"><span class="pre">OSVERSIONINFOEX()</span></code> for more information about these fields.</p> <p>Availability: Windows.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.3.</span></p> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.7: </span>Changed to a named tuple and added <em>service_pack_minor</em>, <em>service_pack_major</em>, <em>suite_mask</em>, and <em>product_type</em>.</p> </div> </dd></dl> <dl class="data"> <dt id="sys.hexversion"> <code class="descclassname">sys.</code><code class="descname">hexversion</code><a class="headerlink" href="#sys.hexversion" title="Permalink to this definition">¶</a></dt> <dd><p>The version number encoded as a single integer. This is guaranteed to increase with each version, including proper support for non-production releases. For example, to test that the Python interpreter is at least version 1.5.2, use:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">hexversion</span> <span class="o">>=</span> <span class="mh">0x010502F0</span><span class="p">:</span> <span class="c1"># use some advanced feature</span> <span class="o">...</span> <span class="k">else</span><span class="p">:</span> <span class="c1"># use an alternative implementation or warn the user</span> <span class="o">...</span> </pre></div> </div> <p>This is called <code class="docutils literal notranslate"><span class="pre">hexversion</span></code> since it only really looks meaningful when viewed as the result of passing it to the built-in <a class="reference internal" href="functions.html#hex" title="hex"><code class="xref py py-func docutils literal notranslate"><span class="pre">hex()</span></code></a> function. The <code class="docutils literal notranslate"><span class="pre">version_info</span></code> value may be used for a more human-friendly encoding of the same information.</p> <p>The <code class="docutils literal notranslate"><span class="pre">hexversion</span></code> is a 32-bit number with the following layout:</p> <table border="1" class="docutils"> <colgroup> <col width="34%" /> <col width="66%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Bits (big endian order)</th> <th class="head">Meaning</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">1-8</span></code></td> <td><code class="docutils literal notranslate"><span class="pre">PY_MAJOR_VERSION</span></code> (the <code class="docutils literal notranslate"><span class="pre">2</span></code> in <code class="docutils literal notranslate"><span class="pre">2.1.0a3</span></code>)</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">9-16</span></code></td> <td><code class="docutils literal notranslate"><span class="pre">PY_MINOR_VERSION</span></code> (the <code class="docutils literal notranslate"><span class="pre">1</span></code> in <code class="docutils literal notranslate"><span class="pre">2.1.0a3</span></code>)</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">17-24</span></code></td> <td><code class="docutils literal notranslate"><span class="pre">PY_MICRO_VERSION</span></code> (the <code class="docutils literal notranslate"><span class="pre">0</span></code> in <code class="docutils literal notranslate"><span class="pre">2.1.0a3</span></code>)</td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">25-28</span></code></td> <td><code class="docutils literal notranslate"><span class="pre">PY_RELEASE_LEVEL</span></code> (<code class="docutils literal notranslate"><span class="pre">0xA</span></code> for alpha, <code class="docutils literal notranslate"><span class="pre">0xB</span></code> for beta, <code class="docutils literal notranslate"><span class="pre">0xC</span></code> for release candidate and <code class="docutils literal notranslate"><span class="pre">0xF</span></code> for final)</td> </tr> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">29-32</span></code></td> <td><code class="docutils literal notranslate"><span class="pre">PY_RELEASE_SERIAL</span></code> (the <code class="docutils literal notranslate"><span class="pre">3</span></code> in <code class="docutils literal notranslate"><span class="pre">2.1.0a3</span></code>, zero for final releases)</td> </tr> </tbody> </table> <p>Thus <code class="docutils literal notranslate"><span class="pre">2.1.0a3</span></code> is hexversion <code class="docutils literal notranslate"><span class="pre">0x020100a3</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 1.5.2.</span></p> </div> </dd></dl> <dl class="data"> <dt id="sys.long_info"> <code class="descclassname">sys.</code><code class="descname">long_info</code><a class="headerlink" href="#sys.long_info" title="Permalink to this definition">¶</a></dt> <dd><p>A struct sequence that holds information about Python’s internal representation of integers. The attributes are read only.</p> <table border="1" class="docutils"> <colgroup> <col width="35%" /> <col width="65%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Attribute</th> <th class="head">Explanation</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">bits_per_digit</span></code></td> <td>number of bits held in each digit. Python integers are stored internally in base <code class="docutils literal notranslate"><span class="pre">2**long_info.bits_per_digit</span></code></td> </tr> <tr class="row-odd"><td><code class="xref py py-const docutils literal notranslate"><span class="pre">sizeof_digit</span></code></td> <td>size in bytes of the C type used to represent a digit</td> </tr> </tbody> </table> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.</span></p> </div> </dd></dl> <dl class="data"> <dt id="sys.last_type"> <code class="descclassname">sys.</code><code class="descname">last_type</code><a class="headerlink" href="#sys.last_type" title="Permalink to this definition">¶</a></dt> <dt id="sys.last_value"> <code class="descclassname">sys.</code><code class="descname">last_value</code><a class="headerlink" href="#sys.last_value" title="Permalink to this definition">¶</a></dt> <dt id="sys.last_traceback"> <code class="descclassname">sys.</code><code class="descname">last_traceback</code><a class="headerlink" href="#sys.last_traceback" title="Permalink to this definition">¶</a></dt> <dd><p>These three variables are not always defined; they are set when an exception is not handled and the interpreter prints an error message and a stack traceback. Their intended use is to allow an interactive user to import a debugger module and engage in post-mortem debugging without having to re-execute the command that caused the error. (Typical use is <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">pdb;</span> <span class="pre">pdb.pm()</span></code> to enter the post-mortem debugger; see chapter <a class="reference internal" href="pdb.html#debugger"><span class="std std-ref">pdb — The Python Debugger</span></a> for more information.)</p> <p>The meaning of the variables is the same as that of the return values from <a class="reference internal" href="#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">exc_info()</span></code></a> above. (Since there is only one interactive thread, thread-safety is not a concern for these variables, unlike for <code class="docutils literal notranslate"><span class="pre">exc_type</span></code> etc.)</p> </dd></dl> <dl class="data"> <dt id="sys.maxint"> <code class="descclassname">sys.</code><code class="descname">maxint</code><a class="headerlink" href="#sys.maxint" title="Permalink to this definition">¶</a></dt> <dd><p>The largest positive integer supported by Python’s regular integer type. This is at least 2**31-1. The largest negative integer is <code class="docutils literal notranslate"><span class="pre">-maxint-1</span></code> — the asymmetry results from the use of 2’s complement binary arithmetic.</p> </dd></dl> <dl class="data"> <dt id="sys.maxsize"> <code class="descclassname">sys.</code><code class="descname">maxsize</code><a class="headerlink" href="#sys.maxsize" title="Permalink to this definition">¶</a></dt> <dd><p>The largest positive integer supported by the platform’s Py_ssize_t type, and thus the maximum size lists, strings, dicts, and many other containers can have.</p> </dd></dl> <dl class="data"> <dt id="sys.maxunicode"> <code class="descclassname">sys.</code><code class="descname">maxunicode</code><a class="headerlink" href="#sys.maxunicode" title="Permalink to this definition">¶</a></dt> <dd><p>An integer giving the largest supported code point for a Unicode character. The value of this depends on the configuration option that specifies whether Unicode characters are stored as UCS-2 or UCS-4.</p> </dd></dl> <dl class="data"> <dt id="sys.meta_path"> <code class="descclassname">sys.</code><code class="descname">meta_path</code><a class="headerlink" href="#sys.meta_path" title="Permalink to this definition">¶</a></dt> <dd><p>A list of <a class="reference internal" href="../glossary.html#term-finder"><span class="xref std std-term">finder</span></a> objects that have their <code class="xref py py-meth docutils literal notranslate"><span class="pre">find_module()</span></code> methods called to see if one of the objects can find the module to be imported. The <code class="xref py py-meth docutils literal notranslate"><span class="pre">find_module()</span></code> method is called at least with the absolute name of the module being imported. If the module to be imported is contained in package then the parent package’s <code class="xref py py-attr docutils literal notranslate"><span class="pre">__path__</span></code> attribute is passed in as a second argument. The method returns <code class="docutils literal notranslate"><span class="pre">None</span></code> if the module cannot be found, else returns a <a class="reference internal" href="../glossary.html#term-loader"><span class="xref std std-term">loader</span></a>.</p> <p><a class="reference internal" href="#sys.meta_path" title="sys.meta_path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.meta_path</span></code></a> is searched before any implicit default finders or <a class="reference internal" href="#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p> <p>See <span class="target" id="index-4"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a> for the original specification.</p> </dd></dl> <dl class="data"> <dt id="sys.modules"> <code class="descclassname">sys.</code><code class="descname">modules</code><a class="headerlink" href="#sys.modules" title="Permalink to this definition">¶</a></dt> <dd><p id="index-5">This is a dictionary that maps module names to modules which have already been loaded. This can be manipulated to force reloading of modules and other tricks. Note that removing a module from this dictionary is <em>not</em> the same as calling <a class="reference internal" href="functions.html#reload" title="reload"><code class="xref py py-func docutils literal notranslate"><span class="pre">reload()</span></code></a> on the corresponding module object.</p> </dd></dl> <dl class="data"> <dt id="sys.path"> <code class="descclassname">sys.</code><code class="descname">path</code><a class="headerlink" href="#sys.path" title="Permalink to this definition">¶</a></dt> <dd><p id="index-6">A list of strings that specifies the search path for modules. Initialized from the environment variable <span class="target" id="index-7"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a>, plus an installation-dependent default.</p> <p>As initialized upon program startup, the first item of this list, <code class="docutils literal notranslate"><span class="pre">path[0]</span></code>, is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), <code class="docutils literal notranslate"><span class="pre">path[0]</span></code> is the empty string, which directs Python to search modules in the current directory first. Notice that the script directory is inserted <em>before</em> the entries inserted as a result of <span class="target" id="index-8"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a>.</p> <p>A program is free to modify this list for its own purposes.</p> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.3: </span>Unicode strings are no longer ignored.</p> </div> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <p class="last">Module <a class="reference internal" href="site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> This describes how to use .pth files to extend <a class="reference internal" href="#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p> </div> </dd></dl> <dl class="data"> <dt id="sys.path_hooks"> <code class="descclassname">sys.</code><code class="descname">path_hooks</code><a class="headerlink" href="#sys.path_hooks" title="Permalink to this definition">¶</a></dt> <dd><p>A list of callables that take a path argument to try to create a <a class="reference internal" href="../glossary.html#term-finder"><span class="xref std std-term">finder</span></a> for the path. If a finder can be created, it is to be returned by the callable, else raise <a class="reference internal" href="exceptions.html#exceptions.ImportError" title="exceptions.ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a>.</p> <p>Originally specified in <span class="target" id="index-9"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a>.</p> </dd></dl> <dl class="data"> <dt id="sys.path_importer_cache"> <code class="descclassname">sys.</code><code class="descname">path_importer_cache</code><a class="headerlink" href="#sys.path_importer_cache" title="Permalink to this definition">¶</a></dt> <dd><p>A dictionary acting as a cache for <a class="reference internal" href="../glossary.html#term-finder"><span class="xref std std-term">finder</span></a> objects. The keys are paths that have been passed to <a class="reference internal" href="#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a> and the values are the finders that are found. If a path is a valid file system path but no explicit finder is found on <a class="reference internal" href="#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a> then <code class="docutils literal notranslate"><span class="pre">None</span></code> is stored to represent the implicit default finder should be used. If the path is not an existing path then <a class="reference internal" href="imp.html#imp.NullImporter" title="imp.NullImporter"><code class="xref py py-class docutils literal notranslate"><span class="pre">imp.NullImporter</span></code></a> is set.</p> <p>Originally specified in <span class="target" id="index-10"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a>.</p> </dd></dl> <dl class="data"> <dt id="sys.platform"> <code class="descclassname">sys.</code><code class="descname">platform</code><a class="headerlink" href="#sys.platform" title="Permalink to this definition">¶</a></dt> <dd><p>This string contains a platform identifier that can be used to append platform-specific components to <a class="reference internal" href="#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>, for instance.</p> <p>For most Unix systems, this is the lowercased OS name as returned by <code class="docutils literal notranslate"><span class="pre">uname</span> <span class="pre">-s</span></code> with the first part of the version as returned by <code class="docutils literal notranslate"><span class="pre">uname</span> <span class="pre">-r</span></code> appended, e.g. <code class="docutils literal notranslate"><span class="pre">'sunos5'</span></code>, <em>at the time when Python was built</em>. Unless you want to test for a specific system version, it is therefore recommended to use the following idiom:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">'freebsd'</span><span class="p">):</span> <span class="c1"># FreeBSD-specific code here...</span> <span class="k">elif</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">'linux'</span><span class="p">):</span> <span class="c1"># Linux-specific code here...</span> </pre></div> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.7.3: </span>Since lots of code check for <code class="docutils literal notranslate"><span class="pre">sys.platform</span> <span class="pre">==</span> <span class="pre">'linux2'</span></code>, and there is no essential change between Linux 2.x and 3.x, <code class="docutils literal notranslate"><span class="pre">sys.platform</span></code> is always set to <code class="docutils literal notranslate"><span class="pre">'linux2'</span></code>, even on Linux 3.x. In Python 3.3 and later, the value will always be set to <code class="docutils literal notranslate"><span class="pre">'linux'</span></code>, so it is recommended to always use the <code class="docutils literal notranslate"><span class="pre">startswith</span></code> idiom presented above.</p> </div> <p>For other systems, the values are:</p> <table border="1" class="docutils"> <colgroup> <col width="44%" /> <col width="56%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">System</th> <th class="head"><a class="reference internal" href="platform.html#module-platform" title="platform: Retrieves as much platform identifying data as possible."><code class="xref py py-data docutils literal notranslate"><span class="pre">platform</span></code></a> value</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>Linux (2.x <em>and</em> 3.x)</td> <td><code class="docutils literal notranslate"><span class="pre">'linux2'</span></code></td> </tr> <tr class="row-odd"><td>Windows</td> <td><code class="docutils literal notranslate"><span class="pre">'win32'</span></code></td> </tr> <tr class="row-even"><td>Windows/Cygwin</td> <td><code class="docutils literal notranslate"><span class="pre">'cygwin'</span></code></td> </tr> <tr class="row-odd"><td>Mac OS X</td> <td><code class="docutils literal notranslate"><span class="pre">'darwin'</span></code></td> </tr> <tr class="row-even"><td>OS/2</td> <td><code class="docutils literal notranslate"><span class="pre">'os2'</span></code></td> </tr> <tr class="row-odd"><td>OS/2 EMX</td> <td><code class="docutils literal notranslate"><span class="pre">'os2emx'</span></code></td> </tr> <tr class="row-even"><td>RiscOS</td> <td><code class="docutils literal notranslate"><span class="pre">'riscos'</span></code></td> </tr> <tr class="row-odd"><td>AtheOS</td> <td><code class="docutils literal notranslate"><span class="pre">'atheos'</span></code></td> </tr> </tbody> </table> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <p><a class="reference internal" href="os.html#os.name" title="os.name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">os.name</span></code></a> has a coarser granularity. <a class="reference internal" href="os.html#os.uname" title="os.uname"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.uname()</span></code></a> gives system-dependent version information.</p> <p class="last">The <a class="reference internal" href="platform.html#module-platform" title="platform: Retrieves as much platform identifying data as possible."><code class="xref py py-mod docutils literal notranslate"><span class="pre">platform</span></code></a> module provides detailed checks for the system’s identity.</p> </div> </dd></dl> <dl class="data"> <dt id="sys.prefix"> <code class="descclassname">sys.</code><code class="descname">prefix</code><a class="headerlink" href="#sys.prefix" title="Permalink to this definition">¶</a></dt> <dd><p>A string giving the site-specific directory prefix where the platform independent Python files are installed; by default, this is the string <code class="docutils literal notranslate"><span class="pre">'/usr/local'</span></code>. This can be set at build time with the <code class="docutils literal notranslate"><span class="pre">--prefix</span></code> argument to the <strong class="program">configure</strong> script. The main collection of Python library modules is installed in the directory <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">X.Y</span></em></code> while the platform independent header files (all except <code class="file docutils literal notranslate"><span class="pre">pyconfig.h</span></code>) are stored in <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/include/python</span><em><span class="pre">X.Y</span></em></code>, where <em>X.Y</em> is the version number of Python, for example <code class="docutils literal notranslate"><span class="pre">2.7</span></code>.</p> </dd></dl> <dl class="data"> <dt id="sys.ps1"> <code class="descclassname">sys.</code><code class="descname">ps1</code><a class="headerlink" href="#sys.ps1" title="Permalink to this definition">¶</a></dt> <dt id="sys.ps2"> <code class="descclassname">sys.</code><code class="descname">ps2</code><a class="headerlink" href="#sys.ps2" title="Permalink to this definition">¶</a></dt> <dd><p id="index-11">Strings specifying the primary and secondary prompt of the interpreter. These are only defined if the interpreter is in interactive mode. Their initial values in this case are <code class="docutils literal notranslate"><span class="pre">'>>></span> <span class="pre">'</span></code> and <code class="docutils literal notranslate"><span class="pre">'...</span> <span class="pre">'</span></code>. If a non-string object is assigned to either variable, its <a class="reference internal" href="functions.html#str" title="str"><code class="xref py py-func docutils literal notranslate"><span class="pre">str()</span></code></a> is re-evaluated each time the interpreter prepares to read a new interactive command; this can be used to implement a dynamic prompt.</p> </dd></dl> <dl class="data"> <dt id="sys.py3kwarning"> <code class="descclassname">sys.</code><code class="descname">py3kwarning</code><a class="headerlink" href="#sys.py3kwarning" title="Permalink to this definition">¶</a></dt> <dd><p>Bool containing the status of the Python 3 warning flag. It’s <code class="docutils literal notranslate"><span class="pre">True</span></code> when Python is started with the -3 option. (This should be considered read-only; setting it to a different value doesn’t have an effect on Python 3 warnings.)</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.setcheckinterval"> <code class="descclassname">sys.</code><code class="descname">setcheckinterval</code><span class="sig-paren">(</span><em>interval</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.setcheckinterval" title="Permalink to this definition">¶</a></dt> <dd><p>Set the interpreter’s “check interval”. This integer value determines how often the interpreter checks for periodic things such as thread switches and signal handlers. The default is <code class="docutils literal notranslate"><span class="pre">100</span></code>, meaning the check is performed every 100 Python virtual instructions. Setting it to a larger value may increase performance for programs using threads. Setting it to a value <code class="docutils literal notranslate"><span class="pre"><=</span></code> 0 checks every virtual instruction, maximizing responsiveness as well as overhead.</p> </dd></dl> <dl class="function"> <dt id="sys.setdefaultencoding"> <code class="descclassname">sys.</code><code class="descname">setdefaultencoding</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.setdefaultencoding" title="Permalink to this definition">¶</a></dt> <dd><p>Set the current default string encoding used by the Unicode implementation. If <em>name</em> does not match any available encoding, <a class="reference internal" href="exceptions.html#exceptions.LookupError" title="exceptions.LookupError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">LookupError</span></code></a> is raised. This function is only intended to be used by the <a class="reference internal" href="site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module implementation and, where needed, by <code class="xref py py-mod docutils literal notranslate"><span class="pre">sitecustomize</span></code>. Once used by the <a class="reference internal" href="site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module, it is removed from the <a class="reference internal" href="#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module’s namespace.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.0.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.setdlopenflags"> <code class="descclassname">sys.</code><code class="descname">setdlopenflags</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.setdlopenflags" title="Permalink to this definition">¶</a></dt> <dd><p>Set the flags used by the interpreter for <code class="xref c c-func docutils literal notranslate"><span class="pre">dlopen()</span></code> calls, such as when the interpreter loads extension modules. Among other things, this will enable a lazy resolving of symbols when importing a module, if called as <code class="docutils literal notranslate"><span class="pre">sys.setdlopenflags(0)</span></code>. To share symbols across extension modules, call as <code class="docutils literal notranslate"><span class="pre">sys.setdlopenflags(dl.RTLD_NOW</span> <span class="pre">|</span> <span class="pre">dl.RTLD_GLOBAL)</span></code>. Symbolic names for the flag modules can be either found in the <a class="reference internal" href="dl.html#module-dl" title="dl: Call C functions in shared objects. (deprecated) (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dl</span></code></a> module, or in the <code class="xref py py-mod docutils literal notranslate"><span class="pre">DLFCN</span></code> module. If <code class="xref py py-mod docutils literal notranslate"><span class="pre">DLFCN</span></code> is not available, it can be generated from <code class="file docutils literal notranslate"><span class="pre">/usr/include/dlfcn.h</span></code> using the <strong class="program">h2py</strong> script. Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.2.</span></p> </div> </dd></dl> <dl class="function"> <dt id="sys.setprofile"> <code class="descclassname">sys.</code><code class="descname">setprofile</code><span class="sig-paren">(</span><em>profilefunc</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.setprofile" title="Permalink to this definition">¶</a></dt> <dd><p id="index-12">Set the system’s profile function, which allows you to implement a Python source code profiler in Python. See chapter <a class="reference internal" href="profile.html#profile"><span class="std std-ref">The Python Profilers</span></a> for more information on the Python profiler. The system’s profile function is called similarly to the system’s trace function (see <a class="reference internal" href="#sys.settrace" title="sys.settrace"><code class="xref py py-func docutils literal notranslate"><span class="pre">settrace()</span></code></a>), but it is called with different events, for example it isn’t called for each executed line of code (only on call and return, but the return event is reported even when an exception has been set). The function is thread-specific, but there is no way for the profiler to know about context switches between threads, so it does not make sense to use this in the presence of multiple threads. Also, its return value is not used, so it can simply return <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> <p>Profile functions should have three arguments: <em>frame</em>, <em>event</em>, and <em>arg</em>. <em>frame</em> is the current stack frame. <em>event</em> is a string: <code class="docutils literal notranslate"><span class="pre">'call'</span></code>, <code class="docutils literal notranslate"><span class="pre">'return'</span></code>, <code class="docutils literal notranslate"><span class="pre">'c_call'</span></code>, <code class="docutils literal notranslate"><span class="pre">'c_return'</span></code>, or <code class="docutils literal notranslate"><span class="pre">'c_exception'</span></code>. <em>arg</em> depends on the event type.</p> <p>The events have the following meaning:</p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">'call'</span></code></dt> <dd>A function is called (or some other code block entered). The profile function is called; <em>arg</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>.</dd> <dt><code class="docutils literal notranslate"><span class="pre">'return'</span></code></dt> <dd>A function (or other code block) is about to return. The profile function is called; <em>arg</em> is the value that will be returned, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the event is caused by an exception being raised.</dd> <dt><code class="docutils literal notranslate"><span class="pre">'c_call'</span></code></dt> <dd>A C function is about to be called. This may be an extension function or a built-in. <em>arg</em> is the C function object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">'c_return'</span></code></dt> <dd>A C function has returned. <em>arg</em> is the C function object.</dd> <dt><code class="docutils literal notranslate"><span class="pre">'c_exception'</span></code></dt> <dd>A C function has raised an exception. <em>arg</em> is the C function object.</dd> </dl> </dd></dl> <dl class="function"> <dt id="sys.setrecursionlimit"> <code class="descclassname">sys.</code><code class="descname">setrecursionlimit</code><span class="sig-paren">(</span><em>limit</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.setrecursionlimit" title="Permalink to this definition">¶</a></dt> <dd><p>Set the maximum depth of the Python interpreter stack to <em>limit</em>. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python.</p> <p>The highest possible limit is platform-dependent. A user may need to set the limit higher when she has a program that requires deep recursion and a platform that supports a higher limit. This should be done with care, because a too-high limit can lead to a crash.</p> </dd></dl> <dl class="function"> <dt id="sys.settrace"> <code class="descclassname">sys.</code><code class="descname">settrace</code><span class="sig-paren">(</span><em>tracefunc</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.settrace" title="Permalink to this definition">¶</a></dt> <dd><p id="index-13">Set the system’s trace function, which allows you to implement a Python source code debugger in Python. The function is thread-specific; for a debugger to support multiple threads, it must be registered using <a class="reference internal" href="#sys.settrace" title="sys.settrace"><code class="xref py py-func docutils literal notranslate"><span class="pre">settrace()</span></code></a> for each thread being debugged.</p> <p>Trace functions should have three arguments: <em>frame</em>, <em>event</em>, and <em>arg</em>. <em>frame</em> is the current stack frame. <em>event</em> is a string: <code class="docutils literal notranslate"><span class="pre">'call'</span></code>, <code class="docutils literal notranslate"><span class="pre">'line'</span></code>, <code class="docutils literal notranslate"><span class="pre">'return'</span></code> or <code class="docutils literal notranslate"><span class="pre">'exception'</span></code>. <em>arg</em> depends on the event type.</p> <p>The trace function is invoked (with <em>event</em> set to <code class="docutils literal notranslate"><span class="pre">'call'</span></code>) whenever a new local scope is entered; it should return a reference to a local trace function to be used that scope, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the scope shouldn’t be traced.</p> <p>The local trace function should return a reference to itself (or to another function for further tracing in that scope), or <code class="docutils literal notranslate"><span class="pre">None</span></code> to turn off tracing in that scope.</p> <p>The events have the following meaning:</p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">'call'</span></code></dt> <dd>A function is called (or some other code block entered). The global trace function is called; <em>arg</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>; the return value specifies the local trace function.</dd> <dt><code class="docutils literal notranslate"><span class="pre">'line'</span></code></dt> <dd>The interpreter is about to execute a new line of code or re-execute the condition of a loop. The local trace function is called; <em>arg</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>; the return value specifies the new local trace function. See <code class="file docutils literal notranslate"><span class="pre">Objects/lnotab_notes.txt</span></code> for a detailed explanation of how this works.</dd> <dt><code class="docutils literal notranslate"><span class="pre">'return'</span></code></dt> <dd>A function (or other code block) is about to return. The local trace function is called; <em>arg</em> is the value that will be returned, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the event is caused by an exception being raised. The trace function’s return value is ignored.</dd> <dt><code class="docutils literal notranslate"><span class="pre">'exception'</span></code></dt> <dd>An exception has occurred. The local trace function is called; <em>arg</em> is a tuple <code class="docutils literal notranslate"><span class="pre">(exception,</span> <span class="pre">value,</span> <span class="pre">traceback)</span></code>; the return value specifies the new local trace function.</dd> </dl> <p>Note that as an exception is propagated down the chain of callers, an <code class="docutils literal notranslate"><span class="pre">'exception'</span></code> event is generated at each level.</p> <p>For more information on code and frame objects, refer to <a class="reference internal" href="../reference/datamodel.html#types"><span class="std std-ref">The standard type hierarchy</span></a>.</p> <div class="impl-detail compound"> <p><strong>CPython implementation detail:</strong> The <a class="reference internal" href="#sys.settrace" title="sys.settrace"><code class="xref py py-func docutils literal notranslate"><span class="pre">settrace()</span></code></a> function is intended only for implementing debuggers, profilers, coverage tools and the like. Its behavior is part of the implementation platform, rather than part of the language definition, and thus may not be available in all Python implementations.</p> </div> </dd></dl> <dl class="function"> <dt id="sys.settscdump"> <code class="descclassname">sys.</code><code class="descname">settscdump</code><span class="sig-paren">(</span><em>on_flag</em><span class="sig-paren">)</span><a class="headerlink" href="#sys.settscdump" title="Permalink to this definition">¶</a></dt> <dd><p>Activate dumping of VM measurements using the Pentium timestamp counter, if <em>on_flag</em> is true. Deactivate these dumps if <em>on_flag</em> is off. The function is available only if Python was compiled with <code class="docutils literal notranslate"><span class="pre">--with-tsc</span></code>. To understand the output of this dump, read <code class="file docutils literal notranslate"><span class="pre">Python/ceval.c</span></code> in the Python sources.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.4.</span></p> </div> <div class="impl-detail compound"> <p><strong>CPython implementation detail:</strong> This function is intimately bound to CPython implementation details and thus not likely to be implemented elsewhere.</p> </div> </dd></dl> <dl class="data"> <dt id="sys.stdin"> <code class="descclassname">sys.</code><code class="descname">stdin</code><a class="headerlink" href="#sys.stdin" title="Permalink to this definition">¶</a></dt> <dt id="sys.stdout"> <code class="descclassname">sys.</code><code class="descname">stdout</code><a class="headerlink" href="#sys.stdout" title="Permalink to this definition">¶</a></dt> <dt id="sys.stderr"> <code class="descclassname">sys.</code><code class="descname">stderr</code><a class="headerlink" href="#sys.stderr" title="Permalink to this definition">¶</a></dt> <dd><p id="index-14">File objects corresponding to the interpreter’s standard input, output and error streams. <code class="docutils literal notranslate"><span class="pre">stdin</span></code> is used for all interpreter input except for scripts but including calls to <a class="reference internal" href="functions.html#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a> and <a class="reference internal" href="functions.html#raw_input" title="raw_input"><code class="xref py py-func docutils literal notranslate"><span class="pre">raw_input()</span></code></a>. <code class="docutils literal notranslate"><span class="pre">stdout</span></code> is used for the output of <a class="reference internal" href="../reference/simple_stmts.html#print"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">print</span></code></a> and <a class="reference internal" href="../glossary.html#term-expression"><span class="xref std std-term">expression</span></a> statements and for the prompts of <a class="reference internal" href="functions.html#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a> and <a class="reference internal" href="functions.html#raw_input" title="raw_input"><code class="xref py py-func docutils literal notranslate"><span class="pre">raw_input()</span></code></a>. The interpreter’s own prompts and (almost all of) its error messages go to <code class="docutils literal notranslate"><span class="pre">stderr</span></code>. <code class="docutils literal notranslate"><span class="pre">stdout</span></code> and <code class="docutils literal notranslate"><span class="pre">stderr</span></code> needn’t be built-in file objects: any object is acceptable as long as it has a <code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code> method that takes a string argument. (Changing these objects doesn’t affect the standard I/O streams of processes executed by <a class="reference internal" href="os.html#os.popen" title="os.popen"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.popen()</span></code></a>, <a class="reference internal" href="os.html#os.system" title="os.system"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.system()</span></code></a> or the <code class="xref py py-func docutils literal notranslate"><span class="pre">exec*()</span></code> family of functions in the <a class="reference internal" href="os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a> module.)</p> </dd></dl> <dl class="data"> <dt id="sys.__stdin__"> <code class="descclassname">sys.</code><code class="descname">__stdin__</code><a class="headerlink" href="#sys.__stdin__" title="Permalink to this definition">¶</a></dt> <dt id="sys.__stdout__"> <code class="descclassname">sys.</code><code class="descname">__stdout__</code><a class="headerlink" href="#sys.__stdout__" title="Permalink to this definition">¶</a></dt> <dt id="sys.__stderr__"> <code class="descclassname">sys.</code><code class="descname">__stderr__</code><a class="headerlink" href="#sys.__stderr__" title="Permalink to this definition">¶</a></dt> <dd><p>These objects contain the original values of <code class="docutils literal notranslate"><span class="pre">stdin</span></code>, <code class="docutils literal notranslate"><span class="pre">stderr</span></code> and <code class="docutils literal notranslate"><span class="pre">stdout</span></code> at the start of the program. They are used during finalization, and could be useful to print to the actual standard stream no matter if the <code class="docutils literal notranslate"><span class="pre">sys.std*</span></code> object has been redirected.</p> <p>It can also be used to restore the actual files to known working file objects in case they have been overwritten with a broken object. However, the preferred way to do this is to explicitly save the previous stream before replacing it, and restore the saved object.</p> </dd></dl> <dl class="data"> <dt id="sys.subversion"> <code class="descclassname">sys.</code><code class="descname">subversion</code><a class="headerlink" href="#sys.subversion" title="Permalink to this definition">¶</a></dt> <dd><p>A triple (repo, branch, version) representing the Subversion information of the Python interpreter. <em>repo</em> is the name of the repository, <code class="docutils literal notranslate"><span class="pre">'CPython'</span></code>. <em>branch</em> is a string of one of the forms <code class="docutils literal notranslate"><span class="pre">'trunk'</span></code>, <code class="docutils literal notranslate"><span class="pre">'branches/name'</span></code> or <code class="docutils literal notranslate"><span class="pre">'tags/name'</span></code>. <em>version</em> is the output of <code class="docutils literal notranslate"><span class="pre">svnversion</span></code>, if the interpreter was built from a Subversion checkout; it contains the revision number (range) and possibly a trailing ‘M’ if there were local modifications. If the tree was exported (or svnversion was not available), it is the revision of <code class="docutils literal notranslate"><span class="pre">Include/patchlevel.h</span></code> if the branch is a tag. Otherwise, it is <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.5.</span></p> </div> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Python is now <a class="reference external" href="https://docs.python.org/devguide/">developed</a> using Mercurial. In recent Python 2.7 bugfix releases, <a class="reference internal" href="#sys.subversion" title="sys.subversion"><code class="xref py py-data docutils literal notranslate"><span class="pre">subversion</span></code></a> therefore contains placeholder information. It is removed in Python 3.3.</p> </div> </dd></dl> <dl class="data"> <dt id="sys.tracebacklimit"> <code class="descclassname">sys.</code><code class="descname">tracebacklimit</code><a class="headerlink" href="#sys.tracebacklimit" title="Permalink to this definition">¶</a></dt> <dd><p>When this variable is set to an integer value, it determines the maximum number of levels of traceback information printed when an unhandled exception occurs. The default is <code class="docutils literal notranslate"><span class="pre">1000</span></code>. When set to <code class="docutils literal notranslate"><span class="pre">0</span></code> or less, all traceback information is suppressed and only the exception type and value are printed.</p> </dd></dl> <dl class="data"> <dt id="sys.version"> <code class="descclassname">sys.</code><code class="descname">version</code><a class="headerlink" href="#sys.version" title="Permalink to this definition">¶</a></dt> <dd><p>A string containing the version number of the Python interpreter plus additional information on the build number and compiler used. This string is displayed when the interactive interpreter is started. Do not extract version information out of it, rather, use <a class="reference internal" href="#sys.version_info" title="sys.version_info"><code class="xref py py-data docutils literal notranslate"><span class="pre">version_info</span></code></a> and the functions provided by the <a class="reference internal" href="platform.html#module-platform" title="platform: Retrieves as much platform identifying data as possible."><code class="xref py py-mod docutils literal notranslate"><span class="pre">platform</span></code></a> module.</p> </dd></dl> <dl class="data"> <dt id="sys.api_version"> <code class="descclassname">sys.</code><code class="descname">api_version</code><a class="headerlink" href="#sys.api_version" title="Permalink to this definition">¶</a></dt> <dd><p>The C API version for this interpreter. Programmers may find this useful when debugging version conflicts between Python and extension modules.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.3.</span></p> </div> </dd></dl> <dl class="data"> <dt id="sys.version_info"> <code class="descclassname">sys.</code><code class="descname">version_info</code><a class="headerlink" href="#sys.version_info" title="Permalink to this definition">¶</a></dt> <dd><p>A tuple containing the five components of the version number: <em>major</em>, <em>minor</em>, <em>micro</em>, <em>releaselevel</em>, and <em>serial</em>. All values except <em>releaselevel</em> are integers; the release level is <code class="docutils literal notranslate"><span class="pre">'alpha'</span></code>, <code class="docutils literal notranslate"><span class="pre">'beta'</span></code>, <code class="docutils literal notranslate"><span class="pre">'candidate'</span></code>, or <code class="docutils literal notranslate"><span class="pre">'final'</span></code>. The <code class="docutils literal notranslate"><span class="pre">version_info</span></code> value corresponding to the Python version 2.0 is <code class="docutils literal notranslate"><span class="pre">(2,</span> <span class="pre">0,</span> <span class="pre">0,</span> <span class="pre">'final',</span> <span class="pre">0)</span></code>. The components can also be accessed by name, so <code class="docutils literal notranslate"><span class="pre">sys.version_info[0]</span></code> is equivalent to <code class="docutils literal notranslate"><span class="pre">sys.version_info.major</span></code> and so on.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.0.</span></p> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.7: </span>Added named component attributes</p> </div> </dd></dl> <dl class="data"> <dt id="sys.warnoptions"> <code class="descclassname">sys.</code><code class="descname">warnoptions</code><a class="headerlink" href="#sys.warnoptions" title="Permalink to this definition">¶</a></dt> <dd><p>This is an implementation detail of the warnings framework; do not modify this value. Refer to the <a class="reference internal" href="warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code></a> module for more information on the warnings framework.</p> </dd></dl> <dl class="data"> <dt id="sys.winver"> <code class="descclassname">sys.</code><code class="descname">winver</code><a class="headerlink" href="#sys.winver" title="Permalink to this definition">¶</a></dt> <dd><p>The version number used to form registry keys on Windows platforms. This is stored as string resource 1000 in the Python DLL. The value is normally the first three characters of <a class="reference internal" href="#sys.version" title="sys.version"><code class="xref py py-const docutils literal notranslate"><span class="pre">version</span></code></a>. It is provided in the <a class="reference internal" href="#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module for informational purposes; modifying this value has no effect on the registry keys used by Python. Availability: Windows.</p> </dd></dl> <p class="rubric">Citations</p> <table class="docutils citation" frame="void" id="c99" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label"><a class="fn-backref" href="#id1">[C99]</a></td><td>ISO/IEC 9899:1999. “Programming languages – C.” A public draft of this standard is available at <a class="reference external" href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf</a>.</td></tr> </tbody> </table> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="python.html" title="previous chapter">28. Python Runtime Services</a></p> <h4>Next topic</h4> <p class="topless"><a href="sysconfig.html" title="next chapter">28.2. <code class="docutils literal notranslate"><span class="pre">sysconfig</span></code> — Provide access to Python’s configuration information</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/library/sys.rst.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="sysconfig.html" title="28.2. sysconfig — Provide access to Python’s configuration information" >next</a> |</li> <li class="right" > <a href="python.html" title="28. Python Runtime Services" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.16 documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="python.html" >28. Python Runtime Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Mar 27, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.7.6. </div> </body> </html>
Save
cmd:
run