Changeset 391 for python/trunk/Doc/tutorial/interpreter.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/tutorial/interpreter.rst
r2 r391 23 23 24 24 On Windows machines, the Python installation is usually placed in 25 :file:`C:\\Python2 6`, though you can change this when you're running the25 :file:`C:\\Python27`, though you can change this when you're running the 26 26 installer. To add this directory to your path, you can type the following 27 27 command into the command prompt in a DOS box:: 28 28 29 set path=%path%;C:\python2 629 set path=%path%;C:\python27 30 30 31 31 Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on … … 59 59 if you had spelled out its full name on the command line. 60 60 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 to63 :func:`input` and :func:`raw_input`, are satisfied from *file*. Since this file64 has already been read until the end by the parser before the program starts65 executing, the program will encounter end-of-file immediately. In the former66 case (which is usually what you want) they are satisfied from whatever file or67 device is connected to standard input of the Python interpreter.68 69 61 When a script file is used, it is sometimes useful to be able to run the script 70 62 and 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.) 63 before the script. 73 64 74 65 … … 79 70 80 71 When 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 72 thereafter are turned into a list of strings and assigned to the ``argv`` 73 variable in the ``sys`` module. You can access this list by executing ``import 74 sys``. The length of the list is at least one; when no script and no arguments 83 75 are given, ``sys.argv[0]`` is an empty string. When the script name is given as 84 76 ``'-'`` (meaning standard input), ``sys.argv[0]`` is set to ``'-'``. When … … 103 95 104 96 python 105 Python 2. 6 (#1, Feb 28 2007, 00:02:06)97 Python 2.7 (#1, Feb 28 2010, 00:02:06) 106 98 Type "help", "copyright", "credits" or "license" for more information. 107 99 >>> … … 174 166 175 167 168 .. _tut-source-encoding: 169 176 170 Source Code Encoding 177 171 -------------------- … … 192 186 For example, to write Unicode literals including the Euro currency symbol, the 193 187 ISO-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 corresponding195 to the Euro symbol) and then exit::188 164. This script, when saved in the ISO-8859-15 encoding, will print the value 189 8364 (the Unicode codepoint corresponding to the Euro symbol) and then exit:: 196 190 197 191 # -*- coding: iso-8859-15 -*- … … 248 242 249 243 244 .. _tut-customize: 245 246 The Customization Modules 247 ------------------------- 248 249 Python 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 251 of 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 257 Now you can create a file named :file:`usercustomize.py` in that directory and 258 put anything you want in it. It will affect every invocation of Python, unless 259 it 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 262 administrator of the computer in the global site-packages directory, and is 263 imported before :mod:`usercustomize`. See the documentation of the :mod:`site` 264 module for more details. 265 266 250 267 .. rubric:: Footnotes 251 268 252 269 .. [#] A problem with the GNU Readline package may prevent this. 253
Note:
See TracChangeset
for help on using the changeset viewer.