Changeset 388 for python/vendor/current/Doc/using
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- Location:
- python/vendor/current/Doc/using
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Doc/using/cmdline.rst
r2 r388 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 -
python/vendor/current/Doc/using/index.rst
r2 r388 1 1 .. _using-index: 2 2 3 ################ 4 Using Python5 ################ 3 ########################## 4 Python Setup and Usage 5 ########################## 6 6 7 7 -
python/vendor/current/Doc/using/mac.rst
r2 r388 26 26 ================================ 27 27 28 Mac OS X 10. 5 comes with Python 2.5.1pre-installed by Apple. If you wish, you28 Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, you 29 29 are invited to install the most recent version of Python from the Python website 30 30 (http://www.python.org). A current "universal binary" build of Python, which … … 33 33 What you get after installing is a number of things: 34 34 35 * A :file:`MacPython 2. 5` folder in your :file:`Applications` folder. In here35 * A :file:`MacPython 2.7` folder in your :file:`Applications` folder. In here 36 36 you find IDLE, the development environment that is a standard part of official 37 37 Python distributions; PythonLauncher, which handles double-clicking Python … … 75 75 :program:`TextMate` (see http://macromates.com/). Other editors include 76 76 :program:`Gvim` (http://macvim.org) and :program:`Aquamacs` 77 (http://aquamacs.org ).77 (http://aquamacs.org/). 78 78 79 79 To run your script from the Terminal window you must make sure that … … 101 101 instead of :program:`python` to start such scripts. 102 102 103 With Python 2. 5, you can use either :program:`python` or :program:`pythonw`.103 With Python 2.7, you can use either :program:`python` or :program:`pythonw`. 104 104 105 105 … … 123 123 124 124 MacPython ships with the standard IDLE development environment. A good 125 introduction to using IDLE can be found at http://hkn.eecs.berkeley.edu/126 dyoo/python/idle_intro/index.html.125 introduction to using IDLE can be found at 126 http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html. 127 127 128 128 … … 134 134 There are several methods to install additional Python packages: 135 135 136 * http://pythonmac.org/packages/ contains selected compiled packages for Python137 2.5, 2.4, and 2.3.138 139 136 * Packages can be installed via the standard Python distutils mode (``python 140 137 setup.py install``). 141 138 142 * Many packages can also be installed via the :program:`setuptools` extension. 139 * Many packages can also be installed via the :program:`setuptools` extension 140 or :program:`pip` wrapper, see http://www.pip-installer.org/. 143 141 144 142 … … 168 166 =========================================== 169 167 170 The "Build Applet" tool that is placed in the MacPython 2. 5folder is fine for168 The "Build Applet" tool that is placed in the MacPython 2.7 folder is fine for 171 169 packaging small Python scripts on your own machine to run as a standard Mac 172 170 application. This tool, however, is not robust enough to distribute Python … … 176 174 :program:`py2app`. More information on installing and using py2app can be found 177 175 at http://undefined.org/python/#py2app. 178 179 180 Application Scripting181 =====================182 183 Python can also be used to script other Mac applications via Apple's Open184 Scripting Architecture (OSA); see http://appscript.sourceforge.net. Appscript is185 a high-level, user-friendly Apple event bridge that allows you to control186 scriptable Mac OS X applications using ordinary Python scripts. Appscript makes187 Python a serious alternative to Apple's own *AppleScript* language for188 automating your Mac. A related package, *PyOSA*, is an OSA language component189 for the Python scripting language, allowing Python code to be executed by any190 OSA-enabled application (Script Editor, Mail, iTunes, etc.). PyOSA makes Python191 a full peer to AppleScript.192 176 193 177 -
python/vendor/current/Doc/using/unix.rst
r2 r388 1 .. highlightlang:: none1 .. highlightlang:: sh 2 2 3 3 .. _using-on-unix: … … 27 27 .. seealso:: 28 28 29 http://www. linux.com/articles/6038329 http://www.debian.org/doc/manuals/maint-guide/first.en.html 30 30 for Debian users 31 http:// linuxmafia.com/pub/linux/suse-linux-internals/chapter35.html31 http://en.opensuse.org/Portal:Packaging 32 32 for OpenSuse users 33 http://docs.fedoraproject.org/ drafts/rpm-guide-en/ch-creating-rpms.html33 http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html 34 34 for Fedora users 35 35 http://www.slackbook.org/html/package-management-making-packages.html … … 56 56 -------------- 57 57 58 To install the newest Python versions on OpenSolaris, install blastwave59 (http://www.blastwave.org/howto.html) and type "pkg_get -i python"at the58 To install the newest Python versions on OpenSolaris, install `blastwave 59 <http://www.blastwave.org/howto.html>`_ and type ``pkg_get -i python`` at the 60 60 prompt. 61 61 … … 66 66 If you want to compile CPython yourself, first thing you should do is get the 67 67 `source <http://python.org/download/source/>`_. You can download either the 68 latest release's source or just grab a fresh `checkout 69 <http://www.python.org/dev/faq/#how-do-i-get-a-checkout-of-the-repository-read-only-and-read-write>`_. 68 latest release's source or just grab a fresh `clone 69 <http://docs.python.org/devguide/setup#getting-the-source-code>`_. (If you want 70 to contribute patches, you will need a clone.) 70 71 71 The build process consists the usual ::72 The build process consists in the usual :: 72 73 73 74 ./configure … … 76 77 77 78 invocations. Configuration options and caveats for specific Unix platforms are 78 extensively documented in the : file:`README` file in the root of the Python79 extensively documented in the :source:`README` file in the root of the Python 79 80 source tree. 80 81 … … 145 146 146 147 Geany is an excellent IDE with support for a lot of languages. For more 147 information, read: http:// geany.uvena.de/148 information, read: http://www.geany.org/ 148 149 149 150 Komodo edit is another extremely good IDE. It also has support for a lot of -
python/vendor/current/Doc/using/windows.rst
r2 r388 48 48 by Richard Dooling, 2006 49 49 50 `Installing on Windows <http://diveintopython. org/installing_python/windows.html>`_50 `Installing on Windows <http://diveintopython.net/installing_python/windows.html>`_ 51 51 in "`Dive into Python: Python from novice to pro 52 <http://diveintopython. org/index.html>`_"52 <http://diveintopython.net/index.html>`_" 53 53 by Mark Pilgrim, 2004, 54 54 ISBN 1-59059-356-1 … … 84 84 settings in Windows. 85 85 86 87 .. _setting-envvars: 86 88 87 89 Excursus: Setting environment variables … … 159 161 :file:`C:\\Python\\Lib\\site-packages\\`. 160 162 161 .. `` this fixes syntax highlighting errors in some editors due to the \\ hackery 162 163 You can add folders to your search path to make Python's import mechanism search 164 in these directories as well. Use :envvar:`PYTHONPATH`, as described in 165 :ref:`using-on-envvars`, to modify :data:`sys.path`. On Windows, paths are 166 separated by semicolons, though, to distinguish them from drive identifiers 167 (:file:`C:\\` etc.). 168 169 .. `` 170 171 Modifying the module search path can also be done through the Windows registry: 172 Edit 173 :file:`HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath\\`, 174 as described above for the environment variable :envvar:`%PYTHONPATH%`. A 175 convenient registry editor is :program:`regedit` (start it by typing "regedit" 176 into :menuselection:`Start --> Run`). 163 This is how :data:`sys.path` is populated on Windows: 164 165 * An empty entry is added at the start, which corresponds to the current 166 directory. 167 168 * If the environment variable :envvar:`PYTHONPATH` exists, as described in 169 :ref:`using-on-envvars`, its entries are added next. Note that on Windows, 170 paths in this variable must be separated by semicolons, to distinguish them 171 from the colon used in drive identifiers (``C:\`` etc.). 172 173 * Additional "application paths" can be added in the registry as subkeys of 174 :samp:`\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath` under both the 175 ``HKEY_CURRENT_USER`` and ``HKEY_LOCAL_MACHINE`` hives. Subkeys which have 176 semicolon-delimited path strings as their default value will cause each path 177 to be added to :data:`sys.path`. (Note that all known installers only use 178 HKLM, so HKCU is typically empty.) 179 180 * If the environment variable :envvar:`PYTHONHOME` is set, it is assumed as 181 "Python Home". Otherwise, the path of the main Python executable is used to 182 locate a "landmark file" (``Lib\os.py``) to deduce the "Python Home". If a 183 Python home is found, the relevant sub-directories added to :data:`sys.path` 184 (``Lib``, ``plat-win``, etc) are based on that folder. Otherwise, the core 185 Python path is constructed from the PythonPath stored in the registry. 186 187 * If the Python Home cannot be located, no :envvar:`PYTHONPATH` is specified in 188 the environment, and no registry entries can be found, a default path with 189 relative entries is used (e.g. ``.\Lib;.\plat-win``, etc). 190 191 The end result of all this is: 192 193 * When running :file:`python.exe`, or any other .exe in the main Python 194 directory (either an installed version, or directly from the PCbuild 195 directory), the core path is deduced, and the core paths in the registry are 196 ignored. Other "application paths" in the registry are always read. 197 198 * When Python is hosted in another .exe (different directory, embedded via COM, 199 etc), the "Python Home" will not be deduced, so the core path from the 200 registry is used. Other "application paths" in the registry are always read. 201 202 * If Python can't find its home and there is no registry (eg, frozen .exe, some 203 very strange installation setup) you get a path with some default, but 204 relative, paths. 177 205 178 206 … … 267 295 `source <http://python.org/download/source/>`_. You can download either the 268 296 latest release's source or just grab a fresh `checkout 269 <http:// www.python.org/dev/faq/#how-do-i-get-a-checkout-of-the-repository-read-only-and-read-write>`_.297 <http://docs.python.org/devguide/setup#checking-out-the-code>`_. 270 298 271 299 For Microsoft Visual C++, which is the compiler with which official Python
Note:
See TracChangeset
for help on using the changeset viewer.