~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-3.5.2-docs-html/using/cmdline.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
 
 
4
 
 
5
<html xmlns="http://www.w3.org/1999/xhtml">
 
6
  <head>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
    
 
9
    <title>1. Command line and environment &mdash; Python 3.5.2 documentation</title>
 
10
    
 
11
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    
 
14
    <script type="text/javascript">
 
15
      var DOCUMENTATION_OPTIONS = {
 
16
        URL_ROOT:    '../',
 
17
        VERSION:     '3.5.2',
 
18
        COLLAPSE_INDEX: false,
 
19
        FILE_SUFFIX: '.html',
 
20
        HAS_SOURCE:  true
 
21
      };
 
22
    </script>
 
23
    <script type="text/javascript" src="../_static/jquery.js"></script>
 
24
    <script type="text/javascript" src="../_static/underscore.js"></script>
 
25
    <script type="text/javascript" src="../_static/doctools.js"></script>
 
26
    <script type="text/javascript" src="../_static/sidebar.js"></script>
 
27
    <link rel="search" type="application/opensearchdescription+xml"
 
28
          title="Search within Python 3.5.2 documentation"
 
29
          href="../_static/opensearch.xml"/>
 
30
    <link rel="author" title="About these documents" href="../about.html" />
 
31
    <link rel="copyright" title="Copyright" href="../copyright.html" />
 
32
    <link rel="top" title="Python 3.5.2 documentation" href="../contents.html" />
 
33
    <link rel="up" title="Python Setup and Usage" href="index.html" />
 
34
    <link rel="next" title="2. Using Python on Unix platforms" href="unix.html" />
 
35
    <link rel="prev" title="Python Setup and Usage" href="index.html" />
 
36
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 
37
    
 
38
    <script type="text/javascript" src="../_static/copybutton.js"></script>
 
39
    <script type="text/javascript" src="../_static/version_switch.js"></script>
 
40
    
 
41
    
 
42
 
 
43
 
 
44
  </head>
 
45
  <body role="document">  
 
46
    <div class="related" role="navigation" aria-label="related navigation">
 
47
      <h3>Navigation</h3>
 
48
      <ul>
 
49
        <li class="right" style="margin-right: 10px">
 
50
          <a href="../genindex.html" title="General Index"
 
51
             accesskey="I">index</a></li>
 
52
        <li class="right" >
 
53
          <a href="../py-modindex.html" title="Python Module Index"
 
54
             >modules</a> |</li>
 
55
        <li class="right" >
 
56
          <a href="unix.html" title="2. Using Python on Unix platforms"
 
57
             accesskey="N">next</a> |</li>
 
58
        <li class="right" >
 
59
          <a href="index.html" title="Python Setup and Usage"
 
60
             accesskey="P">previous</a> |</li>
 
61
        <li><img src="../_static/py.png" alt=""
 
62
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
63
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
64
        <li>
 
65
          <span class="version_switcher_placeholder">3.5.2</span>
 
66
          <a href="../index.html">Documentation </a> &raquo;
 
67
        </li>
 
68
 
 
69
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python Setup and Usage</a> &raquo;</li>
 
70
    <li class="right">
 
71
        
 
72
 
 
73
    <div class="inline-search" style="display: none" role="search">
 
74
        <form class="inline-search" action="../search.html" method="get">
 
75
          <input placeholder="Quick search" type="text" name="q" />
 
76
          <input type="submit" value="Go" />
 
77
          <input type="hidden" name="check_keywords" value="yes" />
 
78
          <input type="hidden" name="area" value="default" />
 
79
        </form>
 
80
    </div>
 
81
    <script type="text/javascript">$('.inline-search').show(0);</script>
 
82
         |
 
83
    </li>
 
84
 
 
85
      </ul>
 
86
    </div>    
 
87
 
 
88
    <div class="document">
 
89
      <div class="documentwrapper">
 
90
        <div class="bodywrapper">
 
91
          <div class="body" role="main">
 
92
            
 
93
  <div class="section" id="command-line-and-environment">
 
94
<span id="using-on-general"></span><h1>1. Command line and environment<a class="headerlink" href="#command-line-and-environment" title="Permalink to this headline">¶</a></h1>
 
95
<p>The CPython interpreter scans the command line and the environment for various
 
96
settings.</p>
 
97
<div class="impl-detail compound">
 
98
<p><strong>CPython implementation detail:</strong> Other implementations&#8217; command line schemes may differ.  See
 
99
<a class="reference internal" href="../reference/introduction.html#implementations"><span>Alternate Implementations</span></a> for further resources.</p>
 
100
</div>
 
101
<div class="section" id="command-line">
 
102
<span id="using-on-cmdline"></span><h2>1.1. Command line<a class="headerlink" href="#command-line" title="Permalink to this headline">¶</a></h2>
 
103
<p>When invoking Python, you may specify any of these options:</p>
 
104
<div class="highlight-sh"><div class="highlight"><pre><span></span>python <span class="o">[</span>-bBdEhiIOqsSuvVWx?<span class="o">]</span> <span class="o">[</span>-c <span class="nb">command</span> <span class="p">|</span> -m module-name <span class="p">|</span> script <span class="p">|</span> - <span class="o">]</span> <span class="o">[</span>args<span class="o">]</span>
 
105
</pre></div>
 
106
</div>
 
107
<p>The most common use case is, of course, a simple invocation of a script:</p>
 
108
<div class="highlight-sh"><div class="highlight"><pre><span></span>python myscript.py
 
109
</pre></div>
 
110
</div>
 
111
<div class="section" id="interface-options">
 
112
<span id="using-on-interface-options"></span><h3>1.1.1. Interface options<a class="headerlink" href="#interface-options" title="Permalink to this headline">¶</a></h3>
 
113
<p>The interpreter interface resembles that of the UNIX shell, but provides some
 
114
additional methods of invocation:</p>
 
115
<ul class="simple">
 
116
<li>When called with standard input connected to a tty device, it prompts for
 
117
commands and executes them until an EOF (an end-of-file character, you can
 
118
produce that with <code class="kbd docutils literal"><span class="pre">Ctrl-D</span></code> on UNIX or <code class="kbd docutils literal"><span class="pre">Ctrl-Z,</span> <span class="pre">Enter</span></code> on Windows) is read.</li>
 
119
<li>When called with a file name argument or with a file as standard input, it
 
120
reads and executes a script from that file.</li>
 
121
<li>When called with a directory name argument, it reads and executes an
 
122
appropriately named script from that directory.</li>
 
123
<li>When called with <code class="docutils literal"><span class="pre">-c</span> <span class="pre">command</span></code>, it executes the Python statement(s) given as
 
124
<em>command</em>.  Here <em>command</em> may contain multiple statements separated by
 
125
newlines. Leading whitespace is significant in Python statements!</li>
 
126
<li>When called with <code class="docutils literal"><span class="pre">-m</span> <span class="pre">module-name</span></code>, the given module is located on the
 
127
Python module path and executed as a script.</li>
 
128
</ul>
 
129
<p>In non-interactive mode, the entire input is parsed before it is executed.</p>
 
130
<p>An interface option terminates the list of options consumed by the interpreter,
 
131
all consecutive arguments will end up in <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal"><span class="pre">sys.argv</span></code></a> &#8211; note that the first
 
132
element, subscript zero (<code class="docutils literal"><span class="pre">sys.argv[0]</span></code>), is a string reflecting the program&#8217;s
 
133
source.</p>
 
134
<dl class="cmdoption">
 
135
<dt id="cmdoption-c">
 
136
<code class="descname">-c</code><code class="descclassname"> &lt;command&gt;</code><a class="headerlink" href="#cmdoption-c" title="Permalink to this definition">¶</a></dt>
 
137
<dd><p>Execute the Python code in <em>command</em>.  <em>command</em> can be one or more
 
138
statements separated by newlines, with significant leading whitespace as in
 
139
normal module code.</p>
 
140
<p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal"><span class="pre">sys.argv</span></code></a> will be
 
141
<code class="docutils literal"><span class="pre">&quot;-c&quot;</span></code> and the current directory will be added to the start of
 
142
<a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a> (allowing modules in that directory to be imported as top
 
143
level modules).</p>
 
144
</dd></dl>
 
145
 
 
146
<dl class="cmdoption">
 
147
<dt id="cmdoption-m">
 
148
<code class="descname">-m</code><code class="descclassname"> &lt;module-name&gt;</code><a class="headerlink" href="#cmdoption-m" title="Permalink to this definition">¶</a></dt>
 
149
<dd><p>Search <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a> for the named module and execute its contents as
 
150
the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where the top-level script is run."><code class="xref py py-mod docutils literal"><span class="pre">__main__</span></code></a> module.</p>
 
151
<p>Since the argument is a <em>module</em> name, you must not give a file extension
 
152
(<code class="docutils literal"><span class="pre">.py</span></code>).  The module name should be a valid absolute Python module name, but
 
153
the implementation may not always enforce this (e.g. it may allow you to
 
154
use a name that includes a hyphen).</p>
 
155
<p>Package names (including namespace packages) are also permitted. When a
 
156
package name is supplied instead
 
157
of a normal module, the interpreter will execute <code class="docutils literal"><span class="pre">&lt;pkg&gt;.__main__</span></code> as
 
158
the main module. This behaviour is deliberately similar to the handling
 
159
of directories and zipfiles that are passed to the interpreter as the
 
160
script argument.</p>
 
161
<div class="admonition note">
 
162
<p class="first admonition-title">Note</p>
 
163
<p class="last">This option cannot be used with built-in modules and extension modules
 
164
written in C, since they do not have Python module files. However, it
 
165
can still be used for precompiled modules, even if the original source
 
166
file is not available.</p>
 
167
</div>
 
168
<p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal"><span class="pre">sys.argv</span></code></a> will be the
 
169
full path to the module file (while the module file is being located, the
 
170
first element will be set to <code class="docutils literal"><span class="pre">&quot;-m&quot;</span></code>). As with the <a class="reference internal" href="#cmdoption-c"><code class="xref std std-option docutils literal"><span class="pre">-c</span></code></a> option,
 
171
the current directory will be added to the start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a>.</p>
 
172
<p>Many standard library modules contain code that is invoked on their execution
 
173
as a script.  An example is the <a class="reference internal" href="../library/timeit.html#module-timeit" title="timeit: Measure the execution time of small code snippets."><code class="xref py py-mod docutils literal"><span class="pre">timeit</span></code></a> module:</p>
 
174
<div class="highlight-sh"><div class="highlight"><pre><span></span>python -mtimeit -s <span class="s1">&#39;setup here&#39;</span> <span class="s1">&#39;benchmarked code here&#39;</span>
 
175
python -mtimeit -h <span class="c1"># for details</span>
 
176
</pre></div>
 
177
</div>
 
178
<div class="admonition seealso">
 
179
<p class="first admonition-title">See also</p>
 
180
<dl class="docutils">
 
181
<dt><a class="reference internal" href="../library/runpy.html#runpy.run_module" title="runpy.run_module"><code class="xref py py-func docutils literal"><span class="pre">runpy.run_module()</span></code></a></dt>
 
182
<dd>Equivalent functionality directly available to Python code</dd>
 
183
</dl>
 
184
<p class="last"><span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0338"><strong>PEP 338</strong></a> &#8211; Executing modules as scripts</p>
 
185
</div>
 
186
<div class="versionchanged">
 
187
<p><span class="versionmodified">Changed in version 3.1: </span>Supply the package name to run a <code class="docutils literal"><span class="pre">__main__</span></code> submodule.</p>
 
188
</div>
 
189
<div class="versionchanged">
 
190
<p><span class="versionmodified">Changed in version 3.4: </span>namespace packages are also supported</p>
 
191
</div>
 
192
</dd></dl>
 
193
 
 
194
<dl class="describe">
 
195
<dt>
 
196
<code class="descname">-</code></dt>
 
197
<dd><p>Read commands from standard input (<a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal"><span class="pre">sys.stdin</span></code></a>).  If standard input is
 
198
a terminal, <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal"><span class="pre">-i</span></code></a> is implied.</p>
 
199
<p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal"><span class="pre">sys.argv</span></code></a> will be
 
200
<code class="docutils literal"><span class="pre">&quot;-&quot;</span></code> and the current directory will be added to the start of
 
201
<a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a>.</p>
 
202
</dd></dl>
 
203
 
 
204
<dl class="describe">
 
205
<dt>
 
206
<code class="descname">&lt;script&gt;</code></dt>
 
207
<dd><p>Execute the Python code contained in <em>script</em>, which must be a filesystem
 
208
path (absolute or relative) referring to either a Python file, a directory
 
209
containing a <code class="docutils literal"><span class="pre">__main__.py</span></code> file, or a zipfile containing a
 
210
<code class="docutils literal"><span class="pre">__main__.py</span></code> file.</p>
 
211
<p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal"><span class="pre">sys.argv</span></code></a> will be the
 
212
script name as given on the command line.</p>
 
213
<p>If the script name refers directly to a Python file, the directory
 
214
containing that file is added to the start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a>, and the
 
215
file is executed as the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where the top-level script is run."><code class="xref py py-mod docutils literal"><span class="pre">__main__</span></code></a> module.</p>
 
216
<p>If the script name refers to a directory or zipfile, the script name is
 
217
added to the start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a> and the <code class="docutils literal"><span class="pre">__main__.py</span></code> file in
 
218
that location is executed as the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where the top-level script is run."><code class="xref py py-mod docutils literal"><span class="pre">__main__</span></code></a> module.</p>
 
219
<div class="admonition seealso">
 
220
<p class="first admonition-title">See also</p>
 
221
<dl class="last docutils">
 
222
<dt><a class="reference internal" href="../library/runpy.html#runpy.run_path" title="runpy.run_path"><code class="xref py py-func docutils literal"><span class="pre">runpy.run_path()</span></code></a></dt>
 
223
<dd>Equivalent functionality directly available to Python code</dd>
 
224
</dl>
 
225
</div>
 
226
</dd></dl>
 
227
 
 
228
<p>If no interface option is given, <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal"><span class="pre">-i</span></code></a> is implied, <code class="docutils literal"><span class="pre">sys.argv[0]</span></code> is
 
229
an empty string (<code class="docutils literal"><span class="pre">&quot;&quot;</span></code>) and the current directory will be added to the
 
230
start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a>.  Also, tab-completion and history editing is
 
231
automatically enabled, if available on your platform (see
 
232
<a class="reference internal" href="../library/site.html#rlcompleter-config"><span>Readline configuration</span></a>).</p>
 
233
<div class="admonition seealso">
 
234
<p class="first admonition-title">See also</p>
 
235
<p class="last"><a class="reference internal" href="../tutorial/interpreter.html#tut-invoking"><span>Invoking the Interpreter</span></a></p>
 
236
</div>
 
237
<div class="versionchanged">
 
238
<p><span class="versionmodified">Changed in version 3.4: </span>Automatic enabling of tab-completion and history editing.</p>
 
239
</div>
 
240
</div>
 
241
<div class="section" id="generic-options">
 
242
<h3>1.1.2. Generic options<a class="headerlink" href="#generic-options" title="Permalink to this headline">¶</a></h3>
 
243
<dl class="cmdoption">
 
244
<dt id="cmdoption-?">
 
245
<code class="descname">-?</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-?" title="Permalink to this definition">¶</a></dt>
 
246
<dt id="cmdoption-h">
 
247
<code class="descname">-h</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-h" title="Permalink to this definition">¶</a></dt>
 
248
<dt id="cmdoption--help">
 
249
<code class="descname">--help</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption--help" title="Permalink to this definition">¶</a></dt>
 
250
<dd><p>Print a short description of all command line options.</p>
 
251
</dd></dl>
 
252
 
 
253
<dl class="cmdoption">
 
254
<dt id="cmdoption-V">
 
255
<code class="descname">-V</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-V" title="Permalink to this definition">¶</a></dt>
 
256
<dt id="cmdoption--version">
 
257
<code class="descname">--version</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption--version" title="Permalink to this definition">¶</a></dt>
 
258
<dd><p>Print the Python version number and exit.  Example output could be:</p>
 
259
<div class="highlight-sh"><div class="highlight"><pre><span></span>Python 3.0
 
260
</pre></div>
 
261
</div>
 
262
</dd></dl>
 
263
 
 
264
</div>
 
265
<div class="section" id="miscellaneous-options">
 
266
<span id="using-on-misc-options"></span><h3>1.1.3. Miscellaneous options<a class="headerlink" href="#miscellaneous-options" title="Permalink to this headline">¶</a></h3>
 
267
<dl class="cmdoption">
 
268
<dt id="cmdoption-b">
 
269
<code class="descname">-b</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-b" title="Permalink to this definition">¶</a></dt>
 
270
<dd><p>Issue a warning when comparing <a class="reference internal" href="../library/functions.html#bytes" title="bytes"><code class="xref py py-class docutils literal"><span class="pre">bytes</span></code></a> or <a class="reference internal" href="../library/functions.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal"><span class="pre">bytearray</span></code></a> with
 
271
<a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal"><span class="pre">str</span></code></a> or <a class="reference internal" href="../library/functions.html#bytes" title="bytes"><code class="xref py py-class docutils literal"><span class="pre">bytes</span></code></a> with <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>.  Issue an error when the
 
272
option is given twice (<code class="xref std std-option docutils literal"><span class="pre">-bb</span></code>).</p>
 
273
<div class="versionchanged">
 
274
<p><span class="versionmodified">Changed in version 3.5: </span>Affects comparisons of <a class="reference internal" href="../library/functions.html#bytes" title="bytes"><code class="xref py py-class docutils literal"><span class="pre">bytes</span></code></a> with <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal"><span class="pre">int</span></code></a>.</p>
 
275
</div>
 
276
</dd></dl>
 
277
 
 
278
<dl class="cmdoption">
 
279
<dt id="cmdoption-B">
 
280
<code class="descname">-B</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-B" title="Permalink to this definition">¶</a></dt>
 
281
<dd><p>If given, Python won&#8217;t try to write <code class="docutils literal"><span class="pre">.pyc</span></code> files on the
 
282
import of source modules.  See also <span class="target" id="index-1"></span><a class="reference internal" href="#envvar-PYTHONDONTWRITEBYTECODE"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONDONTWRITEBYTECODE</span></code></a>.</p>
 
283
</dd></dl>
 
284
 
 
285
<dl class="cmdoption">
 
286
<dt id="cmdoption-d">
 
287
<code class="descname">-d</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-d" title="Permalink to this definition">¶</a></dt>
 
288
<dd><p>Turn on parser debugging output (for wizards only, depending on compilation
 
289
options).  See also <span class="target" id="index-2"></span><a class="reference internal" href="#envvar-PYTHONDEBUG"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONDEBUG</span></code></a>.</p>
 
290
</dd></dl>
 
291
 
 
292
<dl class="cmdoption">
 
293
<dt id="cmdoption-E">
 
294
<code class="descname">-E</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-E" title="Permalink to this definition">¶</a></dt>
 
295
<dd><p>Ignore all <span class="target" id="index-3"></span><code class="xref std std-envvar docutils literal"><span class="pre">PYTHON*</span></code> environment variables, e.g.
 
296
<span class="target" id="index-4"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONPATH</span></code></a> and <span class="target" id="index-5"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONHOME</span></code></a>, that might be set.</p>
 
297
</dd></dl>
 
298
 
 
299
<dl class="cmdoption">
 
300
<dt id="cmdoption-i">
 
301
<code class="descname">-i</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-i" title="Permalink to this definition">¶</a></dt>
 
302
<dd><p>When a script is passed as first argument or the <a class="reference internal" href="#cmdoption-c"><code class="xref std std-option docutils literal"><span class="pre">-c</span></code></a> option is used,
 
303
enter interactive mode after executing the script or the command, even when
 
304
<a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal"><span class="pre">sys.stdin</span></code></a> does not appear to be a terminal.  The
 
305
<span class="target" id="index-6"></span><a class="reference internal" href="#envvar-PYTHONSTARTUP"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONSTARTUP</span></code></a> file is not read.</p>
 
306
<p>This can be useful to inspect global variables or a stack trace when a script
 
307
raises an exception.  See also <span class="target" id="index-7"></span><a class="reference internal" href="#envvar-PYTHONINSPECT"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONINSPECT</span></code></a>.</p>
 
308
</dd></dl>
 
309
 
 
310
<dl class="cmdoption">
 
311
<dt id="cmdoption-I">
 
312
<code class="descname">-I</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-I" title="Permalink to this definition">¶</a></dt>
 
313
<dd><p>Run Python in isolated mode. This also implies -E and -s.
 
314
In isolated mode <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a> contains neither the script&#8217;s directory nor
 
315
the user&#8217;s site-packages directory. All <span class="target" id="index-8"></span><code class="xref std std-envvar docutils literal"><span class="pre">PYTHON*</span></code> environment
 
316
variables are ignored, too. Further restrictions may be imposed to prevent
 
317
the user from injecting malicious code.</p>
 
318
<div class="versionadded">
 
319
<p><span class="versionmodified">New in version 3.4.</span></p>
 
320
</div>
 
321
</dd></dl>
 
322
 
 
323
<dl class="cmdoption">
 
324
<dt id="cmdoption-O">
 
325
<code class="descname">-O</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-O" title="Permalink to this definition">¶</a></dt>
 
326
<dd><p>Turn on basic optimizations.  See also <span class="target" id="index-9"></span><a class="reference internal" href="#envvar-PYTHONOPTIMIZE"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONOPTIMIZE</span></code></a>.</p>
 
327
</dd></dl>
 
328
 
 
329
<dl class="cmdoption">
 
330
<dt id="cmdoption-OO">
 
331
<code class="descname">-OO</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-OO" title="Permalink to this definition">¶</a></dt>
 
332
<dd><p>Discard docstrings in addition to the <a class="reference internal" href="#cmdoption-O"><code class="xref std std-option docutils literal"><span class="pre">-O</span></code></a> optimizations.</p>
 
333
</dd></dl>
 
334
 
 
335
<dl class="cmdoption">
 
336
<dt id="cmdoption-q">
 
337
<code class="descname">-q</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-q" title="Permalink to this definition">¶</a></dt>
 
338
<dd><p>Don&#8217;t display the copyright and version messages even in interactive mode.</p>
 
339
<div class="versionadded">
 
340
<p><span class="versionmodified">New in version 3.2.</span></p>
 
341
</div>
 
342
</dd></dl>
 
343
 
 
344
<dl class="cmdoption">
 
345
<dt id="cmdoption-R">
 
346
<code class="descname">-R</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-R" title="Permalink to this definition">¶</a></dt>
 
347
<dd><p>Kept for compatibility.  On Python 3.3 and greater, hash randomization is
 
348
turned on by default.</p>
 
349
<p>On previous versions of Python, this option turns on hash randomization,
 
350
so that the <a class="reference internal" href="../reference/datamodel.html#object.__hash__" title="object.__hash__"><code class="xref py py-meth docutils literal"><span class="pre">__hash__()</span></code></a> values of str, bytes and datetime
 
351
are &#8220;salted&#8221; with an unpredictable random value.  Although they remain
 
352
constant within an individual Python process, they are not predictable
 
353
between repeated invocations of Python.</p>
 
354
<p>Hash randomization is intended to provide protection against a
 
355
denial-of-service caused by carefully-chosen inputs that exploit the worst
 
356
case performance of a dict construction, O(n^2) complexity.  See
 
357
<a class="reference external" href="http://www.ocert.org/advisories/ocert-2011-003.html">http://www.ocert.org/advisories/ocert-2011-003.html</a> for details.</p>
 
358
<p><span class="target" id="index-10"></span><a class="reference internal" href="#envvar-PYTHONHASHSEED"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONHASHSEED</span></code></a> allows you to set a fixed value for the hash
 
359
seed secret.</p>
 
360
<div class="versionadded">
 
361
<p><span class="versionmodified">New in version 3.2.3.</span></p>
 
362
</div>
 
363
</dd></dl>
 
364
 
 
365
<dl class="cmdoption">
 
366
<dt id="cmdoption-s">
 
367
<code class="descname">-s</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-s" title="Permalink to this definition">¶</a></dt>
 
368
<dd><p>Don&#8217;t add the <a class="reference internal" href="../library/site.html#site.USER_SITE" title="site.USER_SITE"><code class="xref py py-data docutils literal"><span class="pre">user</span> <span class="pre">site-packages</span> <span class="pre">directory</span></code></a> to
 
369
<a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a>.</p>
 
370
<div class="admonition seealso">
 
371
<p class="first admonition-title">See also</p>
 
372
<p class="last"><span class="target" id="index-11"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0370"><strong>PEP 370</strong></a> &#8211; Per user site-packages directory</p>
 
373
</div>
 
374
</dd></dl>
 
375
 
 
376
<dl class="cmdoption">
 
377
<dt id="cmdoption-S">
 
378
<code class="descname">-S</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-S" title="Permalink to this definition">¶</a></dt>
 
379
<dd><p>Disable the import of the module <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal"><span class="pre">site</span></code></a> and the site-dependent
 
380
manipulations of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a> that it entails.  Also disable these
 
381
manipulations if <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal"><span class="pre">site</span></code></a> is explicitly imported later (call
 
382
<a class="reference internal" href="../library/site.html#site.main" title="site.main"><code class="xref py py-func docutils literal"><span class="pre">site.main()</span></code></a> if you want them to be triggered).</p>
 
383
</dd></dl>
 
384
 
 
385
<dl class="cmdoption">
 
386
<dt id="cmdoption-u">
 
387
<code class="descname">-u</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-u" title="Permalink to this definition">¶</a></dt>
 
388
<dd><p>Force the binary layer of the stdout and stderr streams (which is
 
389
available as their <code class="docutils literal"><span class="pre">buffer</span></code> attribute) to be unbuffered. The text I/O
 
390
layer will still be line-buffered if writing to the console, or
 
391
block-buffered if redirected to a non-interactive file.</p>
 
392
<p>See also <span class="target" id="index-12"></span><a class="reference internal" href="#envvar-PYTHONUNBUFFERED"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONUNBUFFERED</span></code></a>.</p>
 
393
</dd></dl>
 
394
 
 
395
<dl class="cmdoption">
 
396
<dt id="cmdoption-v">
 
397
<code class="descname">-v</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-v" title="Permalink to this definition">¶</a></dt>
 
398
<dd><p>Print a message each time a module is initialized, showing the place
 
399
(filename or built-in module) from which it is loaded.  When given twice
 
400
(<code class="xref std std-option docutils literal"><span class="pre">-vv</span></code>), print a message for each file that is checked for when
 
401
searching for a module.  Also provides information on module cleanup at exit.
 
402
See also <span class="target" id="index-13"></span><a class="reference internal" href="#envvar-PYTHONVERBOSE"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONVERBOSE</span></code></a>.</p>
 
403
</dd></dl>
 
404
 
 
405
<span class="target" id="using-on-warnings"></span><dl class="cmdoption">
 
406
<dt id="cmdoption-W">
 
407
<code class="descname">-W</code><code class="descclassname"> arg</code><a class="headerlink" href="#cmdoption-W" title="Permalink to this definition">¶</a></dt>
 
408
<dd><p>Warning control.  Python&#8217;s warning machinery by default prints warning
 
409
messages to <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal"><span class="pre">sys.stderr</span></code></a>.  A typical warning message has the following
 
410
form:</p>
 
411
<div class="highlight-sh"><div class="highlight"><pre><span></span>file:line: category: message
 
412
</pre></div>
 
413
</div>
 
414
<p>By default, each warning is printed once for each source line where it
 
415
occurs.  This option controls how often warnings are printed.</p>
 
416
<p>Multiple <a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal"><span class="pre">-W</span></code></a> options may be given; when a warning matches more than
 
417
one option, the action for the last matching option is performed.  Invalid
 
418
<a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal"><span class="pre">-W</span></code></a> options are ignored (though, a warning message is printed about
 
419
invalid options when the first warning is issued).</p>
 
420
<p>Warnings can also be controlled from within a Python program using the
 
421
<a class="reference internal" href="../library/warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal"><span class="pre">warnings</span></code></a> module.</p>
 
422
<p>The simplest form of argument is one of the following action strings (or a
 
423
unique abbreviation):</p>
 
424
<dl class="docutils">
 
425
<dt><code class="docutils literal"><span class="pre">ignore</span></code></dt>
 
426
<dd>Ignore all warnings.</dd>
 
427
<dt><code class="docutils literal"><span class="pre">default</span></code></dt>
 
428
<dd>Explicitly request the default behavior (printing each warning once per
 
429
source line).</dd>
 
430
<dt><code class="docutils literal"><span class="pre">all</span></code></dt>
 
431
<dd>Print a warning each time it occurs (this may generate many messages if a
 
432
warning is triggered repeatedly for the same source line, such as inside a
 
433
loop).</dd>
 
434
<dt><code class="docutils literal"><span class="pre">module</span></code></dt>
 
435
<dd>Print each warning only the first time it occurs in each module.</dd>
 
436
<dt><code class="docutils literal"><span class="pre">once</span></code></dt>
 
437
<dd>Print each warning only the first time it occurs in the program.</dd>
 
438
<dt><code class="docutils literal"><span class="pre">error</span></code></dt>
 
439
<dd>Raise an exception instead of printing a warning message.</dd>
 
440
</dl>
 
441
<p>The full form of argument is:</p>
 
442
<div class="highlight-sh"><div class="highlight"><pre><span></span>action:message:category:module:line
 
443
</pre></div>
 
444
</div>
 
445
<p>Here, <em>action</em> is as explained above but only applies to messages that match
 
446
the remaining fields.  Empty fields match all values; trailing empty fields
 
447
may be omitted.  The <em>message</em> field matches the start of the warning message
 
448
printed; this match is case-insensitive.  The <em>category</em> field matches the
 
449
warning category.  This must be a class name; the match tests whether the
 
450
actual warning category of the message is a subclass of the specified warning
 
451
category.  The full class name must be given.  The <em>module</em> field matches the
 
452
(fully-qualified) module name; this match is case-sensitive.  The <em>line</em>
 
453
field matches the line number, where zero matches all line numbers and is
 
454
thus equivalent to an omitted line number.</p>
 
455
<div class="admonition seealso">
 
456
<p class="first admonition-title">See also</p>
 
457
<p><a class="reference internal" href="../library/warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal"><span class="pre">warnings</span></code></a> &#8211; the warnings module</p>
 
458
<p><span class="target" id="index-14"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0230"><strong>PEP 230</strong></a> &#8211; Warning framework</p>
 
459
<p class="last"><span class="target" id="index-15"></span><a class="reference internal" href="#envvar-PYTHONWARNINGS"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONWARNINGS</span></code></a></p>
 
460
</div>
 
461
</dd></dl>
 
462
 
 
463
<dl class="cmdoption">
 
464
<dt id="cmdoption-x">
 
465
<code class="descname">-x</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-x" title="Permalink to this definition">¶</a></dt>
 
466
<dd><p>Skip the first line of the source, allowing use of non-Unix forms of
 
467
<code class="docutils literal"><span class="pre">#!cmd</span></code>.  This is intended for a DOS specific hack only.</p>
 
468
<div class="admonition note">
 
469
<p class="first admonition-title">Note</p>
 
470
<p class="last">The line numbers in error messages will be off by one.</p>
 
471
</div>
 
472
</dd></dl>
 
473
 
 
474
<dl class="cmdoption">
 
475
<dt id="cmdoption-X">
 
476
<code class="descname">-X</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-X" title="Permalink to this definition">¶</a></dt>
 
477
<dd><p>Reserved for various implementation-specific options.  CPython currently
 
478
defines the following possible values:</p>
 
479
<ul class="simple">
 
480
<li><code class="docutils literal"><span class="pre">-X</span> <span class="pre">faulthandler</span></code> to enable <a class="reference internal" href="../library/faulthandler.html#module-faulthandler" title="faulthandler: Dump the Python traceback."><code class="xref py py-mod docutils literal"><span class="pre">faulthandler</span></code></a>;</li>
 
481
<li><code class="docutils literal"><span class="pre">-X</span> <span class="pre">showrefcount</span></code> to enable the output of the total reference count
 
482
and memory blocks (only works on debug builds);</li>
 
483
<li><code class="docutils literal"><span class="pre">-X</span> <span class="pre">tracemalloc</span></code> to start tracing Python memory allocations using the
 
484
<a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal"><span class="pre">tracemalloc</span></code></a> module. By default, only the most recent frame is
 
485
stored in a traceback of a trace. Use <code class="docutils literal"><span class="pre">-X</span> <span class="pre">tracemalloc=NFRAME</span></code> to start
 
486
tracing with a traceback limit of <em>NFRAME</em> frames. See the
 
487
<a class="reference internal" href="../library/tracemalloc.html#tracemalloc.start" title="tracemalloc.start"><code class="xref py py-func docutils literal"><span class="pre">tracemalloc.start()</span></code></a> for more information.</li>
 
488
</ul>
 
489
<p>It also allows passing arbitrary values and retrieving them through the
 
490
<a class="reference internal" href="../library/sys.html#sys._xoptions" title="sys._xoptions"><code class="xref py py-data docutils literal"><span class="pre">sys._xoptions</span></code></a> dictionary.</p>
 
491
<div class="versionchanged">
 
492
<p><span class="versionmodified">Changed in version 3.2: </span>It is now allowed to pass <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal"><span class="pre">-X</span></code></a> with CPython.</p>
 
493
</div>
 
494
<div class="versionadded">
 
495
<p><span class="versionmodified">New in version 3.3: </span>The <code class="docutils literal"><span class="pre">-X</span> <span class="pre">faulthandler</span></code> option.</p>
 
496
</div>
 
497
<div class="versionadded">
 
498
<p><span class="versionmodified">New in version 3.4: </span>The <code class="docutils literal"><span class="pre">-X</span> <span class="pre">showrefcount</span></code> and <code class="docutils literal"><span class="pre">-X</span> <span class="pre">tracemalloc</span></code> options.</p>
 
499
</div>
 
500
</dd></dl>
 
501
 
 
502
</div>
 
503
<div class="section" id="options-you-shouldn-t-use">
 
504
<h3>1.1.4. Options you shouldn&#8217;t use<a class="headerlink" href="#options-you-shouldn-t-use" title="Permalink to this headline">¶</a></h3>
 
505
<dl class="cmdoption">
 
506
<dt id="cmdoption-J">
 
507
<code class="descname">-J</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-J" title="Permalink to this definition">¶</a></dt>
 
508
<dd><p>Reserved for use by <a class="reference external" href="http://www.jython.org/">Jython</a>.</p>
 
509
</dd></dl>
 
510
 
 
511
</div>
 
512
</div>
 
513
<div class="section" id="environment-variables">
 
514
<span id="using-on-envvars"></span><h2>1.2. Environment variables<a class="headerlink" href="#environment-variables" title="Permalink to this headline">¶</a></h2>
 
515
<p>These environment variables influence Python&#8217;s behavior, they are processed
 
516
before the command-line switches other than -E or -I.  It is customary that
 
517
command-line switches override environmental variables where there is a
 
518
conflict.</p>
 
519
<dl class="envvar">
 
520
<dt id="envvar-PYTHONHOME">
 
521
<code class="descname">PYTHONHOME</code><a class="headerlink" href="#envvar-PYTHONHOME" title="Permalink to this definition">¶</a></dt>
 
522
<dd><p>Change the location of the standard Python libraries.  By default, the
 
523
libraries are searched in <code class="file docutils literal"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code> and
 
524
<code class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code>, where <code class="file docutils literal"><em><span class="pre">prefix</span></em></code> and
 
525
<code class="file docutils literal"><em><span class="pre">exec_prefix</span></em></code> are installation-dependent directories, both defaulting
 
526
to <code class="file docutils literal"><span class="pre">/usr/local</span></code>.</p>
 
527
<p>When <span class="target" id="index-16"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONHOME</span></code></a> is set to a single directory, its value replaces
 
528
both <code class="file docutils literal"><em><span class="pre">prefix</span></em></code> and <code class="file docutils literal"><em><span class="pre">exec_prefix</span></em></code>.  To specify different values
 
529
for these, set <span class="target" id="index-17"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONHOME</span></code></a> to <code class="file docutils literal"><em><span class="pre">prefix</span></em><span class="pre">:</span><em><span class="pre">exec_prefix</span></em></code>.</p>
 
530
</dd></dl>
 
531
 
 
532
<dl class="envvar">
 
533
<dt id="envvar-PYTHONPATH">
 
534
<code class="descname">PYTHONPATH</code><a class="headerlink" href="#envvar-PYTHONPATH" title="Permalink to this definition">¶</a></dt>
 
535
<dd><p>Augment the default search path for module files.  The format is the same as
 
536
the shell&#8217;s <span class="target" id="index-18"></span><code class="xref std std-envvar docutils literal"><span class="pre">PATH</span></code>: one or more directory pathnames separated by
 
537
<a class="reference internal" href="../library/os.html#os.pathsep" title="os.pathsep"><code class="xref py py-data docutils literal"><span class="pre">os.pathsep</span></code></a> (e.g. colons on Unix or semicolons on Windows).
 
538
Non-existent directories are silently ignored.</p>
 
539
<p>In addition to normal directories, individual <span class="target" id="index-19"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONPATH</span></code></a> entries
 
540
may refer to zipfiles containing pure Python modules (in either source or
 
541
compiled form). Extension modules cannot be imported from zipfiles.</p>
 
542
<p>The default search path is installation dependent, but generally begins with
 
543
<code class="file docutils literal"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code> (see <span class="target" id="index-20"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONHOME</span></code></a> above).  It
 
544
is <em>always</em> appended to <span class="target" id="index-21"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONPATH</span></code></a>.</p>
 
545
<p>An additional directory will be inserted in the search path in front of
 
546
<span class="target" id="index-22"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONPATH</span></code></a> as described above under
 
547
<a class="reference internal" href="#using-on-interface-options"><span>Interface options</span></a>. The search path can be manipulated from
 
548
within a Python program as the variable <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a>.</p>
 
549
</dd></dl>
 
550
 
 
551
<dl class="envvar">
 
552
<dt id="envvar-PYTHONSTARTUP">
 
553
<code class="descname">PYTHONSTARTUP</code><a class="headerlink" href="#envvar-PYTHONSTARTUP" title="Permalink to this definition">¶</a></dt>
 
554
<dd><p>If this is the name of a readable file, the Python commands in that file are
 
555
executed before the first prompt is displayed in interactive mode.  The file
 
556
is executed in the same namespace where interactive commands are executed so
 
557
that objects defined or imported in it can be used without qualification in
 
558
the interactive session.  You can also change the prompts <a class="reference internal" href="../library/sys.html#sys.ps1" title="sys.ps1"><code class="xref py py-data docutils literal"><span class="pre">sys.ps1</span></code></a> and
 
559
<a class="reference internal" href="../library/sys.html#sys.ps2" title="sys.ps2"><code class="xref py py-data docutils literal"><span class="pre">sys.ps2</span></code></a> and the hook <a class="reference internal" href="../library/sys.html#sys.__interactivehook__" title="sys.__interactivehook__"><code class="xref py py-data docutils literal"><span class="pre">sys.__interactivehook__</span></code></a> in this file.</p>
 
560
</dd></dl>
 
561
 
 
562
<dl class="envvar">
 
563
<dt id="envvar-PYTHONOPTIMIZE">
 
564
<code class="descname">PYTHONOPTIMIZE</code><a class="headerlink" href="#envvar-PYTHONOPTIMIZE" title="Permalink to this definition">¶</a></dt>
 
565
<dd><p>If this is set to a non-empty string it is equivalent to specifying the
 
566
<a class="reference internal" href="#cmdoption-O"><code class="xref std std-option docutils literal"><span class="pre">-O</span></code></a> option.  If set to an integer, it is equivalent to specifying
 
567
<a class="reference internal" href="#cmdoption-O"><code class="xref std std-option docutils literal"><span class="pre">-O</span></code></a> multiple times.</p>
 
568
</dd></dl>
 
569
 
 
570
<dl class="envvar">
 
571
<dt id="envvar-PYTHONDEBUG">
 
572
<code class="descname">PYTHONDEBUG</code><a class="headerlink" href="#envvar-PYTHONDEBUG" title="Permalink to this definition">¶</a></dt>
 
573
<dd><p>If this is set to a non-empty string it is equivalent to specifying the
 
574
<a class="reference internal" href="#cmdoption-d"><code class="xref std std-option docutils literal"><span class="pre">-d</span></code></a> option.  If set to an integer, it is equivalent to specifying
 
575
<a class="reference internal" href="#cmdoption-d"><code class="xref std std-option docutils literal"><span class="pre">-d</span></code></a> multiple times.</p>
 
576
</dd></dl>
 
577
 
 
578
<dl class="envvar">
 
579
<dt id="envvar-PYTHONINSPECT">
 
580
<code class="descname">PYTHONINSPECT</code><a class="headerlink" href="#envvar-PYTHONINSPECT" title="Permalink to this definition">¶</a></dt>
 
581
<dd><p>If this is set to a non-empty string it is equivalent to specifying the
 
582
<a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal"><span class="pre">-i</span></code></a> option.</p>
 
583
<p>This variable can also be modified by Python code using <a class="reference internal" href="../library/os.html#os.environ" title="os.environ"><code class="xref py py-data docutils literal"><span class="pre">os.environ</span></code></a>
 
584
to force inspect mode on program termination.</p>
 
585
</dd></dl>
 
586
 
 
587
<dl class="envvar">
 
588
<dt id="envvar-PYTHONUNBUFFERED">
 
589
<code class="descname">PYTHONUNBUFFERED</code><a class="headerlink" href="#envvar-PYTHONUNBUFFERED" title="Permalink to this definition">¶</a></dt>
 
590
<dd><p>If this is set to a non-empty string it is equivalent to specifying the
 
591
<a class="reference internal" href="#cmdoption-u"><code class="xref std std-option docutils literal"><span class="pre">-u</span></code></a> option.</p>
 
592
</dd></dl>
 
593
 
 
594
<dl class="envvar">
 
595
<dt id="envvar-PYTHONVERBOSE">
 
596
<code class="descname">PYTHONVERBOSE</code><a class="headerlink" href="#envvar-PYTHONVERBOSE" title="Permalink to this definition">¶</a></dt>
 
597
<dd><p>If this is set to a non-empty string it is equivalent to specifying the
 
598
<a class="reference internal" href="#cmdoption-v"><code class="xref std std-option docutils literal"><span class="pre">-v</span></code></a> option.  If set to an integer, it is equivalent to specifying
 
599
<a class="reference internal" href="#cmdoption-v"><code class="xref std std-option docutils literal"><span class="pre">-v</span></code></a> multiple times.</p>
 
600
</dd></dl>
 
601
 
 
602
<dl class="envvar">
 
603
<dt id="envvar-PYTHONCASEOK">
 
604
<code class="descname">PYTHONCASEOK</code><a class="headerlink" href="#envvar-PYTHONCASEOK" title="Permalink to this definition">¶</a></dt>
 
605
<dd><p>If this is set, Python ignores case in <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal"><span class="pre">import</span></code></a> statements.  This
 
606
only works on Windows and OS X.</p>
 
607
</dd></dl>
 
608
 
 
609
<dl class="envvar">
 
610
<dt id="envvar-PYTHONDONTWRITEBYTECODE">
 
611
<code class="descname">PYTHONDONTWRITEBYTECODE</code><a class="headerlink" href="#envvar-PYTHONDONTWRITEBYTECODE" title="Permalink to this definition">¶</a></dt>
 
612
<dd><p>If this is set to a non-empty string, Python won&#8217;t try to write <code class="docutils literal"><span class="pre">.pyc</span></code> or
 
613
<code class="docutils literal"><span class="pre">.pyo</span></code> files on the import of source modules.  This is equivalent to
 
614
specifying the <a class="reference internal" href="#cmdoption-B"><code class="xref std std-option docutils literal"><span class="pre">-B</span></code></a> option.</p>
 
615
</dd></dl>
 
616
 
 
617
<dl class="envvar">
 
618
<dt id="envvar-PYTHONHASHSEED">
 
619
<code class="descname">PYTHONHASHSEED</code><a class="headerlink" href="#envvar-PYTHONHASHSEED" title="Permalink to this definition">¶</a></dt>
 
620
<dd><p>If this variable is not set or set to <code class="docutils literal"><span class="pre">random</span></code>, a random value is used
 
621
to seed the hashes of str, bytes and datetime objects.</p>
 
622
<p>If <span class="target" id="index-23"></span><a class="reference internal" href="#envvar-PYTHONHASHSEED"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONHASHSEED</span></code></a> is set to an integer value, it is used as a fixed
 
623
seed for generating the hash() of the types covered by the hash
 
624
randomization.</p>
 
625
<p>Its purpose is to allow repeatable hashing, such as for selftests for the
 
626
interpreter itself, or to allow a cluster of python processes to share hash
 
627
values.</p>
 
628
<p>The integer must be a decimal number in the range [0,4294967295].  Specifying
 
629
the value 0 will disable hash randomization.</p>
 
630
<div class="versionadded">
 
631
<p><span class="versionmodified">New in version 3.2.3.</span></p>
 
632
</div>
 
633
</dd></dl>
 
634
 
 
635
<dl class="envvar">
 
636
<dt id="envvar-PYTHONIOENCODING">
 
637
<code class="descname">PYTHONIOENCODING</code><a class="headerlink" href="#envvar-PYTHONIOENCODING" title="Permalink to this definition">¶</a></dt>
 
638
<dd><p>If this is set before running the interpreter, it overrides the encoding used
 
639
for stdin/stdout/stderr, in the syntax <code class="docutils literal"><span class="pre">encodingname:errorhandler</span></code>.  Both
 
640
the <code class="docutils literal"><span class="pre">encodingname</span></code> and the <code class="docutils literal"><span class="pre">:errorhandler</span></code> parts are optional and have
 
641
the same meaning as in <a class="reference internal" href="../library/stdtypes.html#str.encode" title="str.encode"><code class="xref py py-func docutils literal"><span class="pre">str.encode()</span></code></a>.</p>
 
642
<p>For stderr, the <code class="docutils literal"><span class="pre">:errorhandler</span></code> part is ignored; the handler will always be
 
643
<code class="docutils literal"><span class="pre">'backslashreplace'</span></code>.</p>
 
644
<div class="versionchanged">
 
645
<p><span class="versionmodified">Changed in version 3.4: </span>The <code class="docutils literal"><span class="pre">encodingname</span></code> part is now optional.</p>
 
646
</div>
 
647
</dd></dl>
 
648
 
 
649
<dl class="envvar">
 
650
<dt id="envvar-PYTHONNOUSERSITE">
 
651
<code class="descname">PYTHONNOUSERSITE</code><a class="headerlink" href="#envvar-PYTHONNOUSERSITE" title="Permalink to this definition">¶</a></dt>
 
652
<dd><p>If this is set, Python won&#8217;t add the <a class="reference internal" href="../library/site.html#site.USER_SITE" title="site.USER_SITE"><code class="xref py py-data docutils literal"><span class="pre">user</span> <span class="pre">site-packages</span> <span class="pre">directory</span></code></a> to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal"><span class="pre">sys.path</span></code></a>.</p>
 
653
<div class="admonition seealso">
 
654
<p class="first admonition-title">See also</p>
 
655
<p class="last"><span class="target" id="index-24"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0370"><strong>PEP 370</strong></a> &#8211; Per user site-packages directory</p>
 
656
</div>
 
657
</dd></dl>
 
658
 
 
659
<dl class="envvar">
 
660
<dt id="envvar-PYTHONUSERBASE">
 
661
<code class="descname">PYTHONUSERBASE</code><a class="headerlink" href="#envvar-PYTHONUSERBASE" title="Permalink to this definition">¶</a></dt>
 
662
<dd><p>Defines the <a class="reference internal" href="../library/site.html#site.USER_BASE" title="site.USER_BASE"><code class="xref py py-data docutils literal"><span class="pre">user</span> <span class="pre">base</span> <span class="pre">directory</span></code></a>, which is used to
 
663
compute the path of the <a class="reference internal" href="../library/site.html#site.USER_SITE" title="site.USER_SITE"><code class="xref py py-data docutils literal"><span class="pre">user</span> <span class="pre">site-packages</span> <span class="pre">directory</span></code></a>
 
664
and <a class="reference internal" href="../install/index.html#inst-alt-install-user"><span>Distutils installation paths</span></a> for
 
665
<code class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">install</span> <span class="pre">--user</span></code>.</p>
 
666
<div class="admonition seealso">
 
667
<p class="first admonition-title">See also</p>
 
668
<p class="last"><span class="target" id="index-25"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0370"><strong>PEP 370</strong></a> &#8211; Per user site-packages directory</p>
 
669
</div>
 
670
</dd></dl>
 
671
 
 
672
<dl class="envvar">
 
673
<dt id="envvar-PYTHONEXECUTABLE">
 
674
<code class="descname">PYTHONEXECUTABLE</code><a class="headerlink" href="#envvar-PYTHONEXECUTABLE" title="Permalink to this definition">¶</a></dt>
 
675
<dd><p>If this environment variable is set, <code class="docutils literal"><span class="pre">sys.argv[0]</span></code> will be set to its
 
676
value instead of the value got through the C runtime.  Only works on
 
677
Mac OS X.</p>
 
678
</dd></dl>
 
679
 
 
680
<dl class="envvar">
 
681
<dt id="envvar-PYTHONWARNINGS">
 
682
<code class="descname">PYTHONWARNINGS</code><a class="headerlink" href="#envvar-PYTHONWARNINGS" title="Permalink to this definition">¶</a></dt>
 
683
<dd><p>This is equivalent to the <a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal"><span class="pre">-W</span></code></a> option. If set to a comma
 
684
separated string, it is equivalent to specifying <a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal"><span class="pre">-W</span></code></a> multiple
 
685
times.</p>
 
686
</dd></dl>
 
687
 
 
688
<dl class="envvar">
 
689
<dt id="envvar-PYTHONFAULTHANDLER">
 
690
<code class="descname">PYTHONFAULTHANDLER</code><a class="headerlink" href="#envvar-PYTHONFAULTHANDLER" title="Permalink to this definition">¶</a></dt>
 
691
<dd><p>If this environment variable is set to a non-empty string,
 
692
<a class="reference internal" href="../library/faulthandler.html#faulthandler.enable" title="faulthandler.enable"><code class="xref py py-func docutils literal"><span class="pre">faulthandler.enable()</span></code></a> is called at startup: install a handler for
 
693
<code class="xref py py-const docutils literal"><span class="pre">SIGSEGV</span></code>, <code class="xref py py-const docutils literal"><span class="pre">SIGFPE</span></code>, <code class="xref py py-const docutils literal"><span class="pre">SIGABRT</span></code>, <code class="xref py py-const docutils literal"><span class="pre">SIGBUS</span></code> and
 
694
<code class="xref py py-const docutils literal"><span class="pre">SIGILL</span></code> signals to dump the Python traceback.  This is equivalent to
 
695
<a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal"><span class="pre">-X</span></code></a> <code class="docutils literal"><span class="pre">faulthandler</span></code> option.</p>
 
696
<div class="versionadded">
 
697
<p><span class="versionmodified">New in version 3.3.</span></p>
 
698
</div>
 
699
</dd></dl>
 
700
 
 
701
<dl class="envvar">
 
702
<dt id="envvar-PYTHONTRACEMALLOC">
 
703
<code class="descname">PYTHONTRACEMALLOC</code><a class="headerlink" href="#envvar-PYTHONTRACEMALLOC" title="Permalink to this definition">¶</a></dt>
 
704
<dd><p>If this environment variable is set to a non-empty string, start tracing
 
705
Python memory allocations using the <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal"><span class="pre">tracemalloc</span></code></a> module. The value of
 
706
the variable is the maximum number of frames stored in a traceback of a
 
707
trace. For example, <code class="docutils literal"><span class="pre">PYTHONTRACEMALLOC=1</span></code> stores only the most recent
 
708
frame. See the <a class="reference internal" href="../library/tracemalloc.html#tracemalloc.start" title="tracemalloc.start"><code class="xref py py-func docutils literal"><span class="pre">tracemalloc.start()</span></code></a> for more information.</p>
 
709
<div class="versionadded">
 
710
<p><span class="versionmodified">New in version 3.4.</span></p>
 
711
</div>
 
712
</dd></dl>
 
713
 
 
714
<dl class="envvar">
 
715
<dt id="envvar-PYTHONASYNCIODEBUG">
 
716
<code class="descname">PYTHONASYNCIODEBUG</code><a class="headerlink" href="#envvar-PYTHONASYNCIODEBUG" title="Permalink to this definition">¶</a></dt>
 
717
<dd><p>If this environment variable is set to a non-empty string, enable the
 
718
<a class="reference internal" href="../library/asyncio-dev.html#asyncio-debug-mode"><span>debug mode</span></a> of the <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O, event loop, coroutines and tasks."><code class="xref py py-mod docutils literal"><span class="pre">asyncio</span></code></a> module.</p>
 
719
<div class="versionadded">
 
720
<p><span class="versionmodified">New in version 3.4.</span></p>
 
721
</div>
 
722
</dd></dl>
 
723
 
 
724
<div class="section" id="debug-mode-variables">
 
725
<h3>1.2.1. Debug-mode variables<a class="headerlink" href="#debug-mode-variables" title="Permalink to this headline">¶</a></h3>
 
726
<p>Setting these variables only has an effect in a debug build of Python, that is,
 
727
if Python was configured with the <code class="docutils literal"><span class="pre">--with-pydebug</span></code> build option.</p>
 
728
<dl class="envvar">
 
729
<dt id="envvar-PYTHONTHREADDEBUG">
 
730
<code class="descname">PYTHONTHREADDEBUG</code><a class="headerlink" href="#envvar-PYTHONTHREADDEBUG" title="Permalink to this definition">¶</a></dt>
 
731
<dd><p>If set, Python will print threading debug info.</p>
 
732
</dd></dl>
 
733
 
 
734
<dl class="envvar">
 
735
<dt id="envvar-PYTHONDUMPREFS">
 
736
<code class="descname">PYTHONDUMPREFS</code><a class="headerlink" href="#envvar-PYTHONDUMPREFS" title="Permalink to this definition">¶</a></dt>
 
737
<dd><p>If set, Python will dump objects and reference counts still alive after
 
738
shutting down the interpreter.</p>
 
739
</dd></dl>
 
740
 
 
741
<dl class="envvar">
 
742
<dt id="envvar-PYTHONMALLOCSTATS">
 
743
<code class="descname">PYTHONMALLOCSTATS</code><a class="headerlink" href="#envvar-PYTHONMALLOCSTATS" title="Permalink to this definition">¶</a></dt>
 
744
<dd><p>If set, Python will print memory allocation statistics every time a new
 
745
object arena is created, and on shutdown.</p>
 
746
</dd></dl>
 
747
 
 
748
</div>
 
749
</div>
 
750
</div>
 
751
 
 
752
 
 
753
          </div>
 
754
        </div>
 
755
      </div>
 
756
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
 
757
        <div class="sphinxsidebarwrapper">
 
758
  <h3><a href="../contents.html">Table Of Contents</a></h3>
 
759
  <ul>
 
760
<li><a class="reference internal" href="#">1. Command line and environment</a><ul>
 
761
<li><a class="reference internal" href="#command-line">1.1. Command line</a><ul>
 
762
<li><a class="reference internal" href="#interface-options">1.1.1. Interface options</a></li>
 
763
<li><a class="reference internal" href="#generic-options">1.1.2. Generic options</a></li>
 
764
<li><a class="reference internal" href="#miscellaneous-options">1.1.3. Miscellaneous options</a></li>
 
765
<li><a class="reference internal" href="#options-you-shouldn-t-use">1.1.4. Options you shouldn&#8217;t use</a></li>
 
766
</ul>
 
767
</li>
 
768
<li><a class="reference internal" href="#environment-variables">1.2. Environment variables</a><ul>
 
769
<li><a class="reference internal" href="#debug-mode-variables">1.2.1. Debug-mode variables</a></li>
 
770
</ul>
 
771
</li>
 
772
</ul>
 
773
</li>
 
774
</ul>
 
775
 
 
776
  <h4>Previous topic</h4>
 
777
  <p class="topless"><a href="index.html"
 
778
                        title="previous chapter">Python Setup and Usage</a></p>
 
779
  <h4>Next topic</h4>
 
780
  <p class="topless"><a href="unix.html"
 
781
                        title="next chapter">2. Using Python on Unix platforms</a></p>
 
782
  <div role="note" aria-label="source link">
 
783
    <h3>This Page</h3>
 
784
    <ul class="this-page-menu">
 
785
      <li><a href="../bugs.html">Report a Bug</a></li>
 
786
      <li><a href="../_sources/using/cmdline.txt"
 
787
            rel="nofollow">Show Source</a></li>
 
788
    </ul>
 
789
  </div>
 
790
        </div>
 
791
      </div>
 
792
      <div class="clearer"></div>
 
793
    </div>  
 
794
    <div class="related" role="navigation" aria-label="related navigation">
 
795
      <h3>Navigation</h3>
 
796
      <ul>
 
797
        <li class="right" style="margin-right: 10px">
 
798
          <a href="../genindex.html" title="General Index"
 
799
             >index</a></li>
 
800
        <li class="right" >
 
801
          <a href="../py-modindex.html" title="Python Module Index"
 
802
             >modules</a> |</li>
 
803
        <li class="right" >
 
804
          <a href="unix.html" title="2. Using Python on Unix platforms"
 
805
             >next</a> |</li>
 
806
        <li class="right" >
 
807
          <a href="index.html" title="Python Setup and Usage"
 
808
             >previous</a> |</li>
 
809
        <li><img src="../_static/py.png" alt=""
 
810
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
811
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
812
        <li>
 
813
          <span class="version_switcher_placeholder">3.5.2</span>
 
814
          <a href="../index.html">Documentation </a> &raquo;
 
815
        </li>
 
816
 
 
817
          <li class="nav-item nav-item-1"><a href="index.html" >Python Setup and Usage</a> &raquo;</li>
 
818
    <li class="right">
 
819
        
 
820
 
 
821
    <div class="inline-search" style="display: none" role="search">
 
822
        <form class="inline-search" action="../search.html" method="get">
 
823
          <input placeholder="Quick search" type="text" name="q" />
 
824
          <input type="submit" value="Go" />
 
825
          <input type="hidden" name="check_keywords" value="yes" />
 
826
          <input type="hidden" name="area" value="default" />
 
827
        </form>
 
828
    </div>
 
829
    <script type="text/javascript">$('.inline-search').show(0);</script>
 
830
         |
 
831
    </li>
 
832
 
 
833
      </ul>
 
834
    </div>  
 
835
    <div class="footer">
 
836
    &copy; <a href="../copyright.html">Copyright</a> 2001-2016, Python Software Foundation.
 
837
    <br />
 
838
    The Python Software Foundation is a non-profit corporation.
 
839
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
 
840
    <br />
 
841
    Last updated on Oct 30, 2016.
 
842
    <a href="../bugs.html">Found a bug</a>?
 
843
    <br />
 
844
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
 
845
    </div>
 
846
 
 
847
  </body>
 
848
</html>
 
 
b'\\ No newline at end of file'