Changeset 391 for python/trunk/Doc/using/cmdline.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/using/cmdline.rst
r2 r391 1 1 .. highlightlang:: none 2 3 .. ATTENTION: You probably should update Misc/python.man, too, if you modify 4 .. this file. 2 5 3 6 .. _using-on-general: … … 22 25 When invoking Python, you may specify any of these options:: 23 26 24 python [-BdEiOQs StuUvVWxX3?] [-c command | -m module-name | script | - ] [args]27 python [-BdEiOQsRStuUvVWxX3?] [-c command | -m module-name | script | - ] [args] 25 28 26 29 The most common use case is, of course, a simple invocation of a script:: … … 59 62 .. cmdoption:: -c <command> 60 63 61 Execute the Python code in *command*. *command* can be one or emore64 Execute the Python code in *command*. *command* can be one or more 62 65 statements separated by newlines, with significant leading whitespace as in 63 66 normal module code. … … 79 82 use a name that includes a hyphen). 80 83 84 Package names are also permitted. When a package name is supplied instead 85 of a normal module, the interpreter will execute ``<pkg>.__main__`` as 86 the main module. This behaviour is deliberately similar to the handling 87 of directories and zipfiles that are passed to the interpreter as the 88 script argument. 89 81 90 .. note:: 82 91 … … 98 107 .. seealso:: 99 108 :func:`runpy.run_module` 100 The actual implementation of this feature.109 Equivalent functionality directly available to Python code 101 110 102 111 :pep:`338` -- Executing modules as scripts … … 106 115 .. versionchanged:: 2.5 107 116 The named module can now be located inside a package. 117 118 .. versionchanged:: 2.7 119 Supply the package name to run a ``__main__`` submodule. 120 sys.argv[0] is now set to ``"-m"`` while searching for the module 121 (it was previously incorrectly set to ``"-c"``) 108 122 109 123 … … 240 254 241 255 256 .. cmdoption:: -R 257 258 Turn on hash randomization, so that the :meth:`__hash__` values of str, 259 bytes and datetime objects are "salted" with an unpredictable random value. 260 Although they remain constant within an individual Python process, they are 261 not predictable between repeated invocations of Python. 262 263 This is intended to provide protection against a denial-of-service caused by 264 carefully-chosen inputs that exploit the worst case performance of a dict 265 construction, O(n^2) complexity. See 266 http://www.ocert.org/advisories/ocert-2011-003.html for details. 267 268 Changing hash values affects the order in which keys are retrieved from a 269 dict. Although Python has never made guarantees about this ordering (and it 270 typically varies between 32-bit and 64-bit builds), enough real-world code 271 implicitly relies on this non-guaranteed behavior that the randomization is 272 disabled by default. 273 274 See also :envvar:`PYTHONHASHSEED`. 275 276 .. versionadded:: 2.6.8 277 278 242 279 .. cmdoption:: -s 243 280 244 Don't add user site directory to sys.path 281 Don't add the :data:`user site-packages directory <site.USER_SITE>` to 282 :data:`sys.path`. 245 283 246 284 .. versionadded:: 2.6 … … 301 339 :option:`-W` options are ignored (though, a warning message is printed about 302 340 invalid options when the first warning is issued). 341 342 Starting from Python 2.7, :exc:`DeprecationWarning` and its descendants 343 are ignored by default. The :option:`-Wd` option can be used to re-enable 344 them. 303 345 304 346 Warnings can also be controlled from within a Python program using the … … 332 374 may be omitted. The *message* field matches the start of the warning message 333 375 printed; this match is case-insensitive. The *category* field matches the 334 warning category. This must be a class name; the match test whether the376 warning category. This must be a class name; the match tests whether the 335 377 actual warning category of the message is a subclass of the specified warning 336 378 category. The full class name must be given. The *module* field matches the … … 343 385 344 386 :pep:`230` -- Warning framework 387 388 :envvar:`PYTHONWARNINGS` 345 389 346 390 … … 399 443 --------------------- 400 444 401 These environment variables influence Python's behavior. 445 These environment variables influence Python's behavior, they are processed 446 before the command-line switches other than -E. It is customary that 447 command-line switches override environmental variables where there is a 448 conflict. 402 449 403 450 .. envvar:: PYTHONHOME … … 492 539 493 540 If this is set, Python ignores case in :keyword:`import` statements. This 494 only works on Windows .541 only works on Windows, OS X, OS/2, and RiscOS. 495 542 496 543 … … 498 545 499 546 If this is set, Python won't try to write ``.pyc`` or ``.pyo`` files on the 500 import of source modules. 547 import of source modules. This is equivalent to specifying the :option:`-B` 548 option. 501 549 502 550 .. versionadded:: 2.6 551 552 .. envvar:: PYTHONHASHSEED 553 554 If this variable is set to ``random``, the effect is the same as specifying 555 the :option:`-R` option: a random value is used to seed the hashes of str, 556 bytes and datetime objects. 557 558 If :envvar:`PYTHONHASHSEED` is set to an integer value, it is used as a 559 fixed seed for generating the hash() of the types covered by the hash 560 randomization. 561 562 Its purpose is to allow repeatable hashing, such as for selftests for the 563 interpreter itself, or to allow a cluster of python processes to share hash 564 values. 565 566 The integer must be a decimal number in the range [0,4294967295]. 567 Specifying the value 0 will lead to the same hash values as when hash 568 randomization is disabled. 569 570 .. versionadded:: 2.6.8 571 503 572 504 573 .. envvar:: PYTHONIOENCODING … … 513 582 .. envvar:: PYTHONNOUSERSITE 514 583 515 If this is set, Python won't add the user site directory to sys.path 584 If this is set, Python won't add the :data:`user site-packages directory 585 <site.USER_SITE>` to :data:`sys.path`. 516 586 517 587 .. versionadded:: 2.6 … … 524 594 .. envvar:: PYTHONUSERBASE 525 595 526 Sets the base directory for the user site directory 596 Defines the :data:`user base directory <site.USER_BASE>`, which is used to 597 compute the path of the :data:`user site-packages directory <site.USER_SITE>` 598 and :ref:`Distutils installation paths <inst-alt-install-user>` for ``python 599 setup.py install --user``. 527 600 528 601 .. versionadded:: 2.6 … … 539 612 Mac OS X. 540 613 614 .. envvar:: PYTHONWARNINGS 615 616 This is equivalent to the :option:`-W` option. If set to a comma 617 separated string, it is equivalent to specifying :option:`-W` multiple 618 times. 619 541 620 542 621 Debug-mode variables … … 544 623 545 624 Setting these variables only has an effect in a debug build of Python, that is, 546 if Python was configured with the :option:`--with-pydebug` build option.625 if Python was configured with the ``--with-pydebug`` build option. 547 626 548 627 .. envvar:: PYTHONTHREADDEBUG … … 563 642 If set, Python will print memory allocation statistics every time a new 564 643 object arena is created, and on shutdown. 565
Note:
See TracChangeset
for help on using the changeset viewer.