D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
usr
/
share
/
doc
/
python2-docs
/
html
/
using
/
Filename :
cmdline.html
back
Copy
<!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>1. Command line and environment — 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="2. Using Python on Unix platforms" href="unix.html" /> <link rel="prev" title="Python Setup and Usage" href="index.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="https://docs.python.org/2/using/cmdline.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="unix.html" title="2. Using Python on Unix platforms" accesskey="N">next</a> |</li> <li class="right" > <a href="index.html" title="Python Setup and Usage" 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" accesskey="U">Python Setup and Usage</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="command-line-and-environment"> <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> <p>The CPython interpreter scans the command line and the environment for various settings.</p> <div class="impl-detail compound"> <p><strong>CPython implementation detail:</strong> Other implementations’ command line schemes may differ. See <a class="reference internal" href="../reference/introduction.html#implementations"><span class="std std-ref">Alternate Implementations</span></a> for further resources.</p> </div> <div class="section" id="command-line"> <span id="using-on-cmdline"></span><h2>1.1. Command line<a class="headerlink" href="#command-line" title="Permalink to this headline">¶</a></h2> <p>When invoking Python, you may specify any of these options:</p> <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python <span class="o">[</span>-bBdEiOQsRStuUvVWxX3?<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> </pre></div> </div> <p>The most common use case is, of course, a simple invocation of a script:</p> <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python myscript.py </pre></div> </div> <div class="section" id="interface-options"> <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> <p>The interpreter interface resembles that of the UNIX shell, but provides some additional methods of invocation:</p> <ul class="simple"> <li>When called with standard input connected to a tty device, it prompts for commands and executes them until an EOF (an end-of-file character, you can produce that with <kbd class="kbd docutils literal notranslate">Ctrl-D</kbd> on UNIX or <kbd class="kbd docutils literal notranslate">Ctrl-Z, Enter</kbd> on Windows) is read.</li> <li>When called with a file name argument or with a file as standard input, it reads and executes a script from that file.</li> <li>When called with a directory name argument, it reads and executes an appropriately named script from that directory.</li> <li>When called with <code class="docutils literal notranslate"><span class="pre">-c</span> <span class="pre">command</span></code>, it executes the Python statement(s) given as <em>command</em>. Here <em>command</em> may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements!</li> <li>When called with <code class="docutils literal notranslate"><span class="pre">-m</span> <span class="pre">module-name</span></code>, the given module is located on the Python module path and executed as a script.</li> </ul> <p>In non-interactive mode, the entire input is parsed before it is executed.</p> <p>An interface option terminates the list of options consumed by the interpreter, 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 notranslate"><span class="pre">sys.argv</span></code></a> – note that the first element, subscript zero (<code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code>), is a string reflecting the program’s source.</p> <dl class="cmdoption"> <dt id="cmdoption-c"> <code class="descname">-c</code><code class="descclassname"> <command></code><a class="headerlink" href="#cmdoption-c" title="Permalink to this definition">¶</a></dt> <dd><p>Execute the Python code in <em>command</em>. <em>command</em> can be one or more statements separated by newlines, with significant leading whitespace as in normal module code.</p> <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 notranslate"><span class="pre">sys.argv</span></code></a> will be <code class="docutils literal notranslate"><span class="pre">"-c"</span></code> and 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 notranslate"><span class="pre">sys.path</span></code></a> (allowing modules in that directory to be imported as top level modules).</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-m"> <code class="descname">-m</code><code class="descclassname"> <module-name></code><a class="headerlink" href="#cmdoption-m" title="Permalink to this definition">¶</a></dt> <dd><p>Search <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> for the named module and execute its contents 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 notranslate"><span class="pre">__main__</span></code></a> module.</p> <p>Since the argument is a <em>module</em> name, you must not give a file extension (<code class="docutils literal notranslate"><span class="pre">.py</span></code>). The <code class="docutils literal notranslate"><span class="pre">module-name</span></code> should be a valid Python module name, but the implementation may not always enforce this (e.g. it may allow you to use a name that includes a hyphen).</p> <p>Package names are also permitted. When a package name is supplied instead of a normal module, the interpreter will execute <code class="docutils literal notranslate"><span class="pre"><pkg>.__main__</span></code> as the main module. This behaviour is deliberately similar to the handling of directories and zipfiles that are passed to the interpreter as the script argument.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">This option cannot be used with built-in modules and extension modules written in C, since they do not have Python module files. However, it can still be used for precompiled modules, even if the original source file is not available.</p> </div> <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 notranslate"><span class="pre">sys.argv</span></code></a> will be the full path to the module file. As with the <a class="reference internal" href="#cmdoption-c"><code class="xref std std-option docutils literal notranslate"><span class="pre">-c</span></code></a> option, 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 notranslate"><span class="pre">sys.path</span></code></a>.</p> <p>Many standard library modules contain code that is invoked on their execution 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 notranslate"><span class="pre">timeit</span></code></a> module:</p> <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python -mtimeit -s <span class="s1">'setup here'</span> <span class="s1">'benchmarked code here'</span> python -mtimeit -h <span class="c1"># for details</span> </pre></div> </div> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <dl class="docutils"> <dt><a class="reference internal" href="../library/runpy.html#runpy.run_module" title="runpy.run_module"><code class="xref py py-func docutils literal notranslate"><span class="pre">runpy.run_module()</span></code></a></dt> <dd>Equivalent functionality directly available to Python code</dd> </dl> <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> – Executing modules as scripts</p> </div> <div class="versionadded"> <p><span class="versionmodified">New in version 2.4.</span></p> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.5: </span>The named module can now be located inside a package.</p> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.7: </span>Supply the package name to run a <code class="docutils literal notranslate"><span class="pre">__main__</span></code> submodule. sys.argv[0] is now set to <code class="docutils literal notranslate"><span class="pre">"-m"</span></code> while searching for the module (it was previously incorrectly set to <code class="docutils literal notranslate"><span class="pre">"-c"</span></code>)</p> </div> </dd></dl> <dl class="describe"> <dt> <code class="descname">-</code></dt> <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 notranslate"><span class="pre">sys.stdin</span></code></a>). If standard input is a terminal, <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a> is implied.</p> <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 notranslate"><span class="pre">sys.argv</span></code></a> will be <code class="docutils literal notranslate"><span class="pre">"-"</span></code> and 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 notranslate"><span class="pre">sys.path</span></code></a>.</p> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <dl class="last docutils"> <dt><a class="reference internal" href="../library/runpy.html#runpy.run_path" title="runpy.run_path"><code class="xref py py-func docutils literal notranslate"><span class="pre">runpy.run_path()</span></code></a></dt> <dd>Equivalent functionality directly available to Python code</dd> </dl> </div> </dd></dl> <dl class="describe"> <dt> <code class="descname"><script></code></dt> <dd><p>Execute the Python code contained in <em>script</em>, which must be a filesystem path (absolute or relative) referring to either a Python file, a directory containing a <code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> file, or a zipfile containing a <code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> file.</p> <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 notranslate"><span class="pre">sys.argv</span></code></a> will be the script name as given on the command line.</p> <p>If the script name refers directly to a Python file, the directory 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 notranslate"><span class="pre">sys.path</span></code></a>, and the 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 notranslate"><span class="pre">__main__</span></code></a> module.</p> <p>If the script name refers to a directory or zipfile, the script name 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 notranslate"><span class="pre">sys.path</span></code></a> and the <code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> file in 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 notranslate"><span class="pre">__main__</span></code></a> module.</p> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.5: </span>Directories and zipfiles containing a <code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> file at the top level are now considered valid Python scripts.</p> </div> </dd></dl> <p>If no interface option is given, <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a> is implied, <code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code> is an empty string (<code class="docutils literal notranslate"><span class="pre">""</span></code>) and 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 notranslate"><span class="pre">sys.path</span></code></a>.</p> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <p class="last"><a class="reference internal" href="../tutorial/interpreter.html#tut-invoking"><span class="std std-ref">Invoking the Interpreter</span></a></p> </div> </div> <div class="section" id="generic-options"> <h3>1.1.2. Generic options<a class="headerlink" href="#generic-options" title="Permalink to this headline">¶</a></h3> <dl class="cmdoption"> <dt id="cmdoption"> <code class="descname">-?</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption" title="Permalink to this definition">¶</a></dt> <dt id="cmdoption-h"> <code class="descname">-h</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-h" title="Permalink to this definition">¶</a></dt> <dt id="cmdoption-help"> <code class="descname">--help</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-help" title="Permalink to this definition">¶</a></dt> <dd><p>Print a short description of all command line options.</p> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.5: </span>The <code class="docutils literal notranslate"><span class="pre">--help</span></code> variant.</p> </div> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-v"> <code class="descname">-V</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-v" title="Permalink to this definition">¶</a></dt> <dt id="cmdoption-version"> <code class="descname">--version</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-version" title="Permalink to this definition">¶</a></dt> <dd><p>Print the Python version number and exit. Example output could be:</p> <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>Python <span class="m">2</span>.5.1 </pre></div> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.5: </span>The <code class="docutils literal notranslate"><span class="pre">--version</span></code> variant.</p> </div> </dd></dl> </div> <div class="section" id="miscellaneous-options"> <h3>1.1.3. Miscellaneous options<a class="headerlink" href="#miscellaneous-options" title="Permalink to this headline">¶</a></h3> <dl class="cmdoption"> <dt id="cmdoption-b"> <code class="descname">-b</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-b" title="Permalink to this definition">¶</a></dt> <dd><p>Issue a warning when comparing <a class="reference internal" href="../library/functions.html#unicode" title="unicode"><code class="xref py py-class docutils literal notranslate"><span class="pre">unicode</span></code></a> with <a class="reference internal" href="../library/functions.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>. Issue an error when the option is given twice (<code class="xref std std-option docutils literal notranslate"><span class="pre">-bb</span></code>).</p> <p>Note that, unlike the corresponding Python 3.x flag, this will <strong>not</strong> emit warnings for comparisons between <a class="reference internal" href="../library/functions.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> and <a class="reference internal" href="../library/functions.html#unicode" title="unicode"><code class="xref py py-class docutils literal notranslate"><span class="pre">unicode</span></code></a>. Instead, the <code class="docutils literal notranslate"><span class="pre">str</span></code> instance will be implicitly decoded to <code class="docutils literal notranslate"><span class="pre">unicode</span></code> and Unicode comparison used.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="cmdoption"> <dt id="id1"> <code class="descname">-B</code><code class="descclassname"></code><a class="headerlink" href="#id1" title="Permalink to this definition">¶</a></dt> <dd><p>If given, 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. See also <span class="target" id="index-1"></span><a class="reference internal" href="#envvar-PYTHONDONTWRITEBYTECODE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDONTWRITEBYTECODE</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-d"> <code class="descname">-d</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-d" title="Permalink to this definition">¶</a></dt> <dd><p>Turn on parser debugging output (for wizards only, depending on compilation 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 notranslate"><span class="pre">PYTHONDEBUG</span></code></a>.</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-e"> <code class="descname">-E</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-e" title="Permalink to this definition">¶</a></dt> <dd><p>Ignore all <span class="target" id="index-3"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON*</span></code> environment variables, e.g. <span class="target" id="index-4"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><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 notranslate"><span class="pre">PYTHONHOME</span></code></a>, that might be set.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.2.</span></p> </div> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-i"> <code class="descname">-i</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-i" title="Permalink to this definition">¶</a></dt> <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 notranslate"><span class="pre">-c</span></code></a> option is used, enter interactive mode after executing the script or the command, even when <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a> does not appear to be a terminal. The <span class="target" id="index-6"></span><a class="reference internal" href="#envvar-PYTHONSTARTUP"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code></a> file is not read.</p> <p>This can be useful to inspect global variables or a stack trace when a script 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 notranslate"><span class="pre">PYTHONINSPECT</span></code></a>.</p> </dd></dl> <span class="target" id="using-on-optimizations"></span><dl class="cmdoption"> <dt id="cmdoption-o"> <code class="descname">-O</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-o" title="Permalink to this definition">¶</a></dt> <dd><p>Turn on basic optimizations. This changes the filename extension for compiled (<a class="reference internal" href="../glossary.html#term-bytecode"><span class="xref std std-term">bytecode</span></a>) files from <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> to <code class="docutils literal notranslate"><span class="pre">.pyo</span></code>. See also <span class="target" id="index-8"></span><a class="reference internal" href="#envvar-PYTHONOPTIMIZE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONOPTIMIZE</span></code></a>.</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-oo"> <code class="descname">-OO</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-oo" title="Permalink to this definition">¶</a></dt> <dd><p>Discard docstrings in addition to the <a class="reference internal" href="#cmdoption-o"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> optimizations.</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-q"> <code class="descname">-Q</code><code class="descclassname"> <arg></code><a class="headerlink" href="#cmdoption-q" title="Permalink to this definition">¶</a></dt> <dd><p>Division control. The argument must be one of the following:</p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">old</span></code></dt> <dd>division of int/int and long/long return an int or long (<em>default</em>)</dd> <dt><code class="docutils literal notranslate"><span class="pre">new</span></code></dt> <dd>new division semantics, i.e. division of int/int and long/long returns a float</dd> <dt><code class="docutils literal notranslate"><span class="pre">warn</span></code></dt> <dd>old division semantics with a warning for int/int and long/long</dd> <dt><code class="docutils literal notranslate"><span class="pre">warnall</span></code></dt> <dd>old division semantics with a warning for all uses of the division operator</dd> </dl> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <dl class="docutils"> <dt><code class="file docutils literal notranslate"><span class="pre">Tools/scripts/fixdiv.py</span></code></dt> <dd>for a use of <code class="docutils literal notranslate"><span class="pre">warnall</span></code></dd> </dl> <p class="last"><span class="target" id="index-9"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0238"><strong>PEP 238</strong></a> – Changing the division operator</p> </div> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-r"> <code class="descname">-R</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-r" title="Permalink to this definition">¶</a></dt> <dd><p>Turn on hash randomization, so that the <a class="reference internal" href="../reference/datamodel.html#object.__hash__" title="object.__hash__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__hash__()</span></code></a> values of str, bytes and datetime objects are “salted” with an unpredictable random value. Although they remain constant within an individual Python process, they are not predictable between repeated invocations of Python.</p> <p>This is intended to provide protection against a denial-of-service caused by carefully-chosen inputs that exploit the worst case performance of a dict construction, O(n^2) complexity. See <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> <p>Changing hash values affects the order in which keys are retrieved from a dict. Although Python has never made guarantees about this ordering (and it typically varies between 32-bit and 64-bit builds), enough real-world code implicitly relies on this non-guaranteed behavior that the randomization is disabled by default.</p> <p>See also <span class="target" id="index-10"></span><a class="reference internal" href="#envvar-PYTHONHASHSEED"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHASHSEED</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.8.</span></p> </div> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-s"> <code class="descname">-s</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-s" title="Permalink to this definition">¶</a></dt> <dd><p>Don’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 notranslate"><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 notranslate"><span class="pre">sys.path</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <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> – Per user site-packages directory</p> </div> </dd></dl> <dl class="cmdoption"> <dt id="id2"> <code class="descname">-S</code><code class="descclassname"></code><a class="headerlink" href="#id2" title="Permalink to this definition">¶</a></dt> <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 notranslate"><span class="pre">site</span></code></a> and the site-dependent manipulations of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> that it entails.</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-t"> <code class="descname">-t</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-t" title="Permalink to this definition">¶</a></dt> <dd><p>Issue a warning when a source file mixes tabs and spaces for indentation in a way that makes it depend on the worth of a tab expressed in spaces. Issue an error when the option is given twice (<code class="xref std std-option docutils literal notranslate"><span class="pre">-tt</span></code>).</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-u"> <code class="descname">-u</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-u" title="Permalink to this definition">¶</a></dt> <dd><p>Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode.</p> <p>Note that there is internal buffering in <a class="reference internal" href="../library/stdtypes.html#file.readlines" title="file.readlines"><code class="xref py py-meth docutils literal notranslate"><span class="pre">file.readlines()</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#bltin-file-objects"><span class="std std-ref">File Objects</span></a> (<code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">line</span> <span class="pre">in</span> <span class="pre">sys.stdin</span></code>) which is not influenced by this option. To work around this, you will want to use <a class="reference internal" href="../library/stdtypes.html#file.readline" title="file.readline"><code class="xref py py-meth docutils literal notranslate"><span class="pre">file.readline()</span></code></a> inside a <code class="docutils literal notranslate"><span class="pre">while</span> <span class="pre">1:</span></code> loop.</p> <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 notranslate"><span class="pre">PYTHONUNBUFFERED</span></code></a>.</p> </dd></dl> <dl class="cmdoption"> <dt id="id3"> <code class="descname">-v</code><code class="descclassname"></code><a class="headerlink" href="#id3" title="Permalink to this definition">¶</a></dt> <dd><p>Print a message each time a module is initialized, showing the place (filename or built-in module) from which it is loaded. When given twice (<code class="xref std std-option docutils literal notranslate"><span class="pre">-vv</span></code>), print a message for each file that is checked for when searching for a module. Also provides information on module cleanup at exit. See also <span class="target" id="index-13"></span><a class="reference internal" href="#envvar-PYTHONVERBOSE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONVERBOSE</span></code></a>.</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-w"> <code class="descname">-W</code><code class="descclassname"> arg</code><a class="headerlink" href="#cmdoption-w" title="Permalink to this definition">¶</a></dt> <dd><p>Warning control. Python’s warning machinery by default prints warning messages to <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a>. A typical warning message has the following form:</p> <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>file:line: category: message </pre></div> </div> <p>By default, each warning is printed once for each source line where it occurs. This option controls how often warnings are printed.</p> <p>Multiple <a class="reference internal" href="#cmdoption-w"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> options may be given; when a warning matches more than one option, the action for the last matching option is performed. Invalid <a class="reference internal" href="#cmdoption-w"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> options are ignored (though, a warning message is printed about invalid options when the first warning is issued).</p> <p>Starting from Python 2.7, <a class="reference internal" href="../library/exceptions.html#exceptions.DeprecationWarning" title="exceptions.DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> and its descendants are ignored by default. The <code class="xref std std-option docutils literal notranslate"><span class="pre">-Wd</span></code> option can be used to re-enable them.</p> <p>Warnings can also be controlled from within a Python program using the <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 notranslate"><span class="pre">warnings</span></code></a> module.</p> <p>The simplest form of argument is one of the following action strings (or a unique abbreviation) by themselves:</p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">ignore</span></code></dt> <dd>Ignore all warnings.</dd> <dt><code class="docutils literal notranslate"><span class="pre">default</span></code></dt> <dd>Explicitly request the default behavior (printing each warning once per source line).</dd> <dt><code class="docutils literal notranslate"><span class="pre">all</span></code></dt> <dd>Print a warning each time it occurs (this may generate many messages if a warning is triggered repeatedly for the same source line, such as inside a loop).</dd> <dt><code class="docutils literal notranslate"><span class="pre">module</span></code></dt> <dd>Print each warning only the first time it occurs in each module.</dd> <dt><code class="docutils literal notranslate"><span class="pre">once</span></code></dt> <dd>Print each warning only the first time it occurs in the program.</dd> <dt><code class="docutils literal notranslate"><span class="pre">error</span></code></dt> <dd>Raise an exception instead of printing a warning message.</dd> </dl> <p>The full form of argument is:</p> <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>action:message:category:module:line </pre></div> </div> <p>Here, <em>action</em> is as explained above but only applies to messages that match the remaining fields. Empty fields match all values; trailing empty fields may be omitted. The <em>message</em> field matches the start of the warning message printed; this match is case-insensitive. The <em>category</em> field matches the warning category. This must be a class name; the match tests whether the actual warning category of the message is a subclass of the specified warning category. The full class name must be given. The <em>module</em> field matches the (fully-qualified) module name; this match is case-sensitive. The <em>line</em> field matches the line number, where zero matches all line numbers and is thus equivalent to an omitted line number.</p> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <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 notranslate"><span class="pre">warnings</span></code></a> – the warnings module</p> <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> – Warning framework</p> <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 notranslate"><span class="pre">PYTHONWARNINGS</span></code></a></p> </div> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-x"> <code class="descname">-x</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-x" title="Permalink to this definition">¶</a></dt> <dd><p>Skip the first line of the source, allowing use of non-Unix forms of <code class="docutils literal notranslate"><span class="pre">#!cmd</span></code>. This is intended for a DOS specific hack only.</p> </dd></dl> <dl class="cmdoption"> <dt id="cmdoption-3"> <code class="descname">-3</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-3" title="Permalink to this definition">¶</a></dt> <dd><p>Warn about Python 3.x possible incompatibilities by emitting a <a class="reference internal" href="../library/exceptions.html#exceptions.DeprecationWarning" title="exceptions.DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> for features that are removed or significantly changed in Python 3 and can’t be detected using static code analysis.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> <p>See <a class="reference internal" href="../howto/pyporting.html"><span class="doc">Porting Python 2 Code to Python 3</span></a> for more details.</p> </dd></dl> </div> <div class="section" id="options-you-shouldn-t-use"> <h3>1.1.4. Options you shouldn’t use<a class="headerlink" href="#options-you-shouldn-t-use" title="Permalink to this headline">¶</a></h3> <dl class="cmdoption"> <dt id="cmdoption-j"> <code class="descname">-J</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-j" title="Permalink to this definition">¶</a></dt> <dd><p>Reserved for use by <a class="reference external" href="http://www.jython.org/">Jython</a>.</p> </dd></dl> <dl class="cmdoption"> <dt id="id4"> <code class="descname">-U</code><code class="descclassname"></code><a class="headerlink" href="#id4" title="Permalink to this definition">¶</a></dt> <dd><p>Turns all string literals into unicodes globally. Do not be tempted to use this option as it will probably break your world. It also produces <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files with a different magic number than normal. Instead, you can enable unicode literals on a per-module basis by using:</p> <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>from __future__ import unicode_literals </pre></div> </div> <p>at the top of the file. See <a class="reference internal" href="../library/__future__.html#module-__future__" title="__future__: Future statement definitions"><code class="xref py py-mod docutils literal notranslate"><span class="pre">__future__</span></code></a> for details.</p> </dd></dl> <dl class="cmdoption"> <dt id="id5"> <code class="descname">-X</code><code class="descclassname"></code><a class="headerlink" href="#id5" title="Permalink to this definition">¶</a></dt> <dd><p>Reserved for alternative implementations of Python to use for their own purposes.</p> </dd></dl> </div> </div> <div class="section" id="environment-variables"> <span id="using-on-envvars"></span><h2>1.2. Environment variables<a class="headerlink" href="#environment-variables" title="Permalink to this headline">¶</a></h2> <p>These environment variables influence Python’s behavior, they are processed before the command-line switches other than -E. It is customary that command-line switches override environmental variables where there is a conflict.</p> <dl class="envvar"> <dt id="envvar-PYTHONHOME"> <code class="descname">PYTHONHOME</code><a class="headerlink" href="#envvar-PYTHONHOME" title="Permalink to this definition">¶</a></dt> <dd><p>Change the location of the standard Python libraries. By default, the libraries are searched in <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code> and <code class="file docutils literal notranslate"><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 notranslate"><em><span class="pre">prefix</span></em></code> and <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em></code> are installation-dependent directories, both defaulting to <code class="file docutils literal notranslate"><span class="pre">/usr/local</span></code>.</p> <p>When <span class="target" id="index-16"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a> is set to a single directory, its value replaces both <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em></code> and <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em></code>. To specify different values 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 notranslate"><span class="pre">PYTHONHOME</span></code></a> to <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">:</span><em><span class="pre">exec_prefix</span></em></code>.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONPATH"> <code class="descname">PYTHONPATH</code><a class="headerlink" href="#envvar-PYTHONPATH" title="Permalink to this definition">¶</a></dt> <dd><p>Augment the default search path for module files. The format is the same as the shell’s <span class="target" id="index-18"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>: one or more directory pathnames separated by <a class="reference internal" href="../library/os.html#os.pathsep" title="os.pathsep"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.pathsep</span></code></a> (e.g. colons on Unix or semicolons on Windows). Non-existent directories are silently ignored.</p> <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 notranslate"><span class="pre">PYTHONPATH</span></code></a> entries may refer to zipfiles containing pure Python modules (in either source or compiled form). Extension modules cannot be imported from zipfiles.</p> <p>The default search path is installation dependent, but generally begins with <code class="file docutils literal notranslate"><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 notranslate"><span class="pre">PYTHONHOME</span></code></a> above). It 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 notranslate"><span class="pre">PYTHONPATH</span></code></a>.</p> <p>An additional directory will be inserted in the search path in front of <span class="target" id="index-22"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a> as described above under <a class="reference internal" href="#using-on-interface-options"><span class="std std-ref">Interface options</span></a>. The search path can be manipulated from 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 notranslate"><span class="pre">sys.path</span></code></a>.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONSTARTUP"> <code class="descname">PYTHONSTARTUP</code><a class="headerlink" href="#envvar-PYTHONSTARTUP" title="Permalink to this definition">¶</a></dt> <dd><p>If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode. The file is executed in the same namespace where interactive commands are executed so that objects defined or imported in it can be used without qualification in 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 notranslate"><span class="pre">sys.ps1</span></code></a> and <a class="reference internal" href="../library/sys.html#sys.ps2" title="sys.ps2"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.ps2</span></code></a> in this file.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONY2K"> <code class="descname">PYTHONY2K</code><a class="headerlink" href="#envvar-PYTHONY2K" title="Permalink to this definition">¶</a></dt> <dd><p>Set this to a non-empty string to cause the <a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module to require dates specified as strings to include 4-digit years, otherwise 2-digit years are converted based on rules described in the <a class="reference internal" href="../library/time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module documentation.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONOPTIMIZE"> <code class="descname">PYTHONOPTIMIZE</code><a class="headerlink" href="#envvar-PYTHONOPTIMIZE" title="Permalink to this definition">¶</a></dt> <dd><p>If this is set to a non-empty string it is equivalent to specifying the <a class="reference internal" href="#cmdoption-o"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> option. If set to an integer, it is equivalent to specifying <a class="reference internal" href="#cmdoption-o"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> multiple times.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONDEBUG"> <code class="descname">PYTHONDEBUG</code><a class="headerlink" href="#envvar-PYTHONDEBUG" title="Permalink to this definition">¶</a></dt> <dd><p>If this is set to a non-empty string it is equivalent to specifying the <a class="reference internal" href="#cmdoption-d"><code class="xref std std-option docutils literal notranslate"><span class="pre">-d</span></code></a> option. If set to an integer, it is equivalent to specifying <a class="reference internal" href="#cmdoption-d"><code class="xref std std-option docutils literal notranslate"><span class="pre">-d</span></code></a> multiple times.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONINSPECT"> <code class="descname">PYTHONINSPECT</code><a class="headerlink" href="#envvar-PYTHONINSPECT" title="Permalink to this definition">¶</a></dt> <dd><p>If this is set to a non-empty string it is equivalent to specifying the <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a> option.</p> <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 notranslate"><span class="pre">os.environ</span></code></a> to force inspect mode on program termination.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONUNBUFFERED"> <code class="descname">PYTHONUNBUFFERED</code><a class="headerlink" href="#envvar-PYTHONUNBUFFERED" title="Permalink to this definition">¶</a></dt> <dd><p>If this is set to a non-empty string it is equivalent to specifying the <a class="reference internal" href="#cmdoption-u"><code class="xref std std-option docutils literal notranslate"><span class="pre">-u</span></code></a> option.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONVERBOSE"> <code class="descname">PYTHONVERBOSE</code><a class="headerlink" href="#envvar-PYTHONVERBOSE" title="Permalink to this definition">¶</a></dt> <dd><p>If this is set to a non-empty string it is equivalent to specifying the <a class="reference internal" href="#id3"><code class="xref std std-option docutils literal notranslate"><span class="pre">-v</span></code></a> option. If set to an integer, it is equivalent to specifying <a class="reference internal" href="#id3"><code class="xref std std-option docutils literal notranslate"><span class="pre">-v</span></code></a> multiple times.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONCASEOK"> <code class="descname">PYTHONCASEOK</code><a class="headerlink" href="#envvar-PYTHONCASEOK" title="Permalink to this definition">¶</a></dt> <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 notranslate"><span class="pre">import</span></code></a> statements. This only works on Windows, OS X, OS/2, and RiscOS.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONDONTWRITEBYTECODE"> <code class="descname">PYTHONDONTWRITEBYTECODE</code><a class="headerlink" href="#envvar-PYTHONDONTWRITEBYTECODE" title="Permalink to this definition">¶</a></dt> <dd><p>If this is set, 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 is equivalent to specifying the <a class="reference internal" href="#id1"><code class="xref std std-option docutils literal notranslate"><span class="pre">-B</span></code></a> option.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONHASHSEED"> <code class="descname">PYTHONHASHSEED</code><a class="headerlink" href="#envvar-PYTHONHASHSEED" title="Permalink to this definition">¶</a></dt> <dd><p>If this variable is set to <code class="docutils literal notranslate"><span class="pre">random</span></code>, the effect is the same as specifying the <a class="reference internal" href="#cmdoption-r"><code class="xref std std-option docutils literal notranslate"><span class="pre">-R</span></code></a> option: a random value is used to seed the hashes of str, bytes and datetime objects.</p> <p>If <span class="target" id="index-23"></span><a class="reference internal" href="#envvar-PYTHONHASHSEED"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHASHSEED</span></code></a> is set to an integer value, it is used as a fixed seed for generating the hash() of the types covered by the hash randomization.</p> <p>Its purpose is to allow repeatable hashing, such as for selftests for the interpreter itself, or to allow a cluster of python processes to share hash values.</p> <p>The integer must be a decimal number in the range [0,4294967295]. Specifying the value 0 will lead to the same hash values as when hash randomization is disabled.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.8.</span></p> </div> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONIOENCODING"> <code class="descname">PYTHONIOENCODING</code><a class="headerlink" href="#envvar-PYTHONIOENCODING" title="Permalink to this definition">¶</a></dt> <dd><p>Overrides the encoding used for stdin/stdout/stderr, in the syntax <code class="docutils literal notranslate"><span class="pre">encodingname:errorhandler</span></code>. The <code class="docutils literal notranslate"><span class="pre">:errorhandler</span></code> part is optional and has 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 notranslate"><span class="pre">str.encode()</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONNOUSERSITE"> <code class="descname">PYTHONNOUSERSITE</code><a class="headerlink" href="#envvar-PYTHONNOUSERSITE" title="Permalink to this definition">¶</a></dt> <dd><p>If this is set, Python won’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 notranslate"><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 notranslate"><span class="pre">sys.path</span></code></a>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <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> – Per user site-packages directory</p> </div> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONUSERBASE"> <code class="descname">PYTHONUSERBASE</code><a class="headerlink" href="#envvar-PYTHONUSERBASE" title="Permalink to this definition">¶</a></dt> <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 notranslate"><span class="pre">user</span> <span class="pre">base</span> <span class="pre">directory</span></code></a>, which is used to 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 notranslate"><span class="pre">user</span> <span class="pre">site-packages</span> <span class="pre">directory</span></code></a> and <a class="reference internal" href="../install/index.html#inst-alt-install-user"><span class="std std-ref">Distutils installation paths</span></a> for <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">install</span> <span class="pre">--user</span></code>.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <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> – Per user site-packages directory</p> </div> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONEXECUTABLE"> <code class="descname">PYTHONEXECUTABLE</code><a class="headerlink" href="#envvar-PYTHONEXECUTABLE" title="Permalink to this definition">¶</a></dt> <dd><p>If this environment variable is set, <code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code> will be set to its value instead of the value got through the C runtime. Only works on Mac OS X.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONWARNINGS"> <code class="descname">PYTHONWARNINGS</code><a class="headerlink" href="#envvar-PYTHONWARNINGS" title="Permalink to this definition">¶</a></dt> <dd><p>This is equivalent to the <a class="reference internal" href="#cmdoption-w"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> option. If set to a comma separated string, it is equivalent to specifying <a class="reference internal" href="#cmdoption-w"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> multiple times.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONHTTPSVERIFY"> <code class="descname">PYTHONHTTPSVERIFY</code><a class="headerlink" href="#envvar-PYTHONHTTPSVERIFY" title="Permalink to this definition">¶</a></dt> <dd><p>If this environment variable is set specifically to <code class="docutils literal notranslate"><span class="pre">0</span></code>, then it is equivalent to implicitly calling <a class="reference internal" href="../library/ssl.html#ssl._https_verify_certificates" title="ssl._https_verify_certificates"><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl._https_verify_certificates()</span></code></a> with <code class="docutils literal notranslate"><span class="pre">enable=False</span></code> when <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> is first imported.</p> <p>Refer to the documentation of <a class="reference internal" href="../library/ssl.html#ssl._https_verify_certificates" title="ssl._https_verify_certificates"><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl._https_verify_certificates()</span></code></a> for details.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.12.</span></p> </div> </dd></dl> <div class="section" id="debug-mode-variables"> <h3>1.2.1. Debug-mode variables<a class="headerlink" href="#debug-mode-variables" title="Permalink to this headline">¶</a></h3> <p>Setting these variables only has an effect in a debug build of Python, that is, if Python was configured with the <code class="docutils literal notranslate"><span class="pre">--with-pydebug</span></code> build option.</p> <dl class="envvar"> <dt id="envvar-PYTHONTHREADDEBUG"> <code class="descname">PYTHONTHREADDEBUG</code><a class="headerlink" href="#envvar-PYTHONTHREADDEBUG" title="Permalink to this definition">¶</a></dt> <dd><p>If set, Python will print threading debug info.</p> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.6: </span>Previously, this variable was called <code class="docutils literal notranslate"><span class="pre">THREADDEBUG</span></code>.</p> </div> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONDUMPREFS"> <code class="descname">PYTHONDUMPREFS</code><a class="headerlink" href="#envvar-PYTHONDUMPREFS" title="Permalink to this definition">¶</a></dt> <dd><p>If set, Python will dump objects and reference counts still alive after shutting down the interpreter.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONMALLOCSTATS"> <code class="descname">PYTHONMALLOCSTATS</code><a class="headerlink" href="#envvar-PYTHONMALLOCSTATS" title="Permalink to this definition">¶</a></dt> <dd><p>If set, Python will print memory allocation statistics every time a new object arena is created, and on shutdown.</p> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONSHOWALLOCCOUNT"> <code class="descname">PYTHONSHOWALLOCCOUNT</code><a class="headerlink" href="#envvar-PYTHONSHOWALLOCCOUNT" title="Permalink to this definition">¶</a></dt> <dd><p>If set and Python was compiled with <code class="docutils literal notranslate"><span class="pre">COUNT_ALLOCS</span></code> defined, Python will dump allocations counts into stderr on shutdown.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.15.</span></p> </div> </dd></dl> <dl class="envvar"> <dt id="envvar-PYTHONSHOWREFCOUNT"> <code class="descname">PYTHONSHOWREFCOUNT</code><a class="headerlink" href="#envvar-PYTHONSHOWREFCOUNT" title="Permalink to this definition">¶</a></dt> <dd><p>If set, Python will print the total reference count when the program finishes or after each statement in the interactive interpreter.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.15.</span></p> </div> </dd></dl> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">1. Command line and environment</a><ul> <li><a class="reference internal" href="#command-line">1.1. Command line</a><ul> <li><a class="reference internal" href="#interface-options">1.1.1. Interface options</a></li> <li><a class="reference internal" href="#generic-options">1.1.2. Generic options</a></li> <li><a class="reference internal" href="#miscellaneous-options">1.1.3. Miscellaneous options</a></li> <li><a class="reference internal" href="#options-you-shouldn-t-use">1.1.4. Options you shouldn’t use</a></li> </ul> </li> <li><a class="reference internal" href="#environment-variables">1.2. Environment variables</a><ul> <li><a class="reference internal" href="#debug-mode-variables">1.2.1. Debug-mode variables</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="index.html" title="previous chapter">Python Setup and Usage</a></p> <h4>Next topic</h4> <p class="topless"><a href="unix.html" title="next chapter">2. Using Python on Unix platforms</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/using/cmdline.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="unix.html" title="2. Using Python on Unix platforms" >next</a> |</li> <li class="right" > <a href="index.html" title="Python Setup and Usage" >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" >Python Setup and Usage</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>
Name
Size
Last Modified
Owner
Permissions
Actions
cmdline.html
65.271
KB
March 27 2019 12:19:27
root
0644
index.html
11.229
KB
March 27 2019 12:19:27
root
0644
mac.html
19.378
KB
March 27 2019 12:19:27
root
0644
unix.html
16.8
KB
March 27 2019 12:19:27
root
0644
windows.html
29.109
KB
March 27 2019 12:19:27
root
0644
2017 © D7net | D704T team