Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/tutorial/interpreter.rst

    r2 r391  
    2323
    2424On Windows machines, the Python installation is usually placed in
    25 :file:`C:\\Python26`, though you can change this when you're running the
     25:file:`C:\\Python27`, though you can change this when you're running the
    2626installer.  To add this directory to your path,  you can type the following
    2727command into the command prompt in a DOS box::
    2828
    29    set path=%path%;C:\python26
     29   set path=%path%;C:\python27
    3030
    3131Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on
     
    5959if you had spelled out its full name on the command line.
    6060
    61 Note that there is a difference between ``python file`` and ``python <file``.
    62 In the latter case, input requests from the program, such as calls to
    63 :func:`input` and :func:`raw_input`, are satisfied from *file*.  Since this file
    64 has already been read until the end by the parser before the program starts
    65 executing, the program will encounter end-of-file immediately.  In the former
    66 case (which is usually what you want) they are satisfied from whatever file or
    67 device is connected to standard input of the Python interpreter.
    68 
    6961When a script file is used, it is sometimes useful to be able to run the script
    7062and enter interactive mode afterwards.  This can be done by passing :option:`-i`
    71 before the script.  (This does not work if the script is read from standard
    72 input, for the same reason as explained in the previous paragraph.)
     63before the script.
    7364
    7465
     
    7970
    8071When known to the interpreter, the script name and additional arguments
    81 thereafter are passed to the script in the variable ``sys.argv``, which is a
    82 list of strings.  Its length is at least one; when no script and no arguments
     72thereafter are turned into a list of strings and assigned to the ``argv``
     73variable in the ``sys`` module.  You can access this list by executing ``import
     74sys``.  The length of the list is at least one; when no script and no arguments
    8375are given, ``sys.argv[0]`` is an empty string.  When the script name is given as
    8476``'-'`` (meaning  standard input), ``sys.argv[0]`` is set to ``'-'``.  When
     
    10395
    10496   python
    105    Python 2.6 (#1, Feb 28 2007, 00:02:06)
     97   Python 2.7 (#1, Feb 28 2010, 00:02:06)
    10698   Type "help", "copyright", "credits" or "license" for more information.
    10799   >>>
     
    174166
    175167
     168.. _tut-source-encoding:
     169
    176170Source Code Encoding
    177171--------------------
     
    192186For example, to write Unicode literals including the Euro currency symbol, the
    193187ISO-8859-15 encoding can be used, with the Euro symbol having the ordinal value
    194 164.  This script will print the value 8364 (the Unicode codepoint corresponding
    195 to the Euro symbol) and then exit::
     188164.  This script, when saved in the ISO-8859-15 encoding, will print the value
     1898364 (the Unicode codepoint corresponding to the Euro symbol) and then exit::
    196190
    197191   # -*- coding: iso-8859-15 -*-
     
    248242
    249243
     244.. _tut-customize:
     245
     246The Customization Modules
     247-------------------------
     248
     249Python provides two hooks to let you customize it: :mod:`sitecustomize` and
     250:mod:`usercustomize`.  To see how it works, you need first to find the location
     251of your user site-packages directory.  Start Python and run this code:
     252
     253   >>> import site
     254   >>> site.getusersitepackages()
     255   '/home/user/.local/lib/python2.7/site-packages'
     256
     257Now you can create a file named :file:`usercustomize.py` in that directory and
     258put anything you want in it.  It will affect every invocation of Python, unless
     259it is started with the :option:`-s` option to disable the automatic import.
     260
     261:mod:`sitecustomize` works in the same way, but is typically created by an
     262administrator of the computer in the global site-packages directory, and is
     263imported before :mod:`usercustomize`.  See the documentation of the :mod:`site`
     264module for more details.
     265
     266
    250267.. rubric:: Footnotes
    251268
    252269.. [#] A problem with the GNU Readline package may prevent this.
    253 
Note: See TracChangeset for help on using the changeset viewer.