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/introduction.rst

    r2 r391  
    8383error will occur::
    8484
    85    >>> # try to access an undefined variable
    86    ... n
     85   >>> n  # try to access an undefined variable
    8786   Traceback (most recent call last):
    8887     File "<stdin>", line 1, in <module>
     
    179178   '"Isn\'t," she said.'
    180179
     180The interpreter prints the result of string operations in the same way as they
     181are typed for input: inside quotes, and with quotes and other funny characters
     182escaped by backslashes, to show the precise value.  The string is enclosed in
     183double quotes if the string contains a single quote and no double quotes, else
     184it's enclosed in single quotes.  The :keyword:`print` statement produces a more
     185readable output for such input strings.
     186
    181187String literals can span multiple lines in several ways.  Continuation lines can
    182188be used, with a backslash as the last character on the line indicating that the
     
    190196   print hello
    191197
    192 Note that newlines still need to be embedded in the string using ``\n``; the
     198Note that newlines still need to be embedded in the string using ``\n`` -- the
    193199newline following the trailing backslash is discarded.  This example would print
    194200the following:
     
    233239   This is a rather long string containing\n\
    234240   several lines of text much as you would do in C.
    235 
    236 The interpreter prints the result of string operations in the same way as they
    237 are typed for input: inside quotes, and with quotes and other funny characters
    238 escaped by backslashes, to show the precise value.  The string is enclosed in
    239 double quotes if the string contains a single quote and no double quotes, else
    240 it's enclosed in single quotes.  (The :keyword:`print` statement, described
    241 later, can be used to write strings without quotes or escapes.)
    242241
    243242Strings can be concatenated (glued together) with the ``+`` operator, and
     
    523522   >>> 3*a[:3] + ['Boo!']
    524523   ['spam', 'eggs', 100, 'spam', 'eggs', 100, 'spam', 'eggs', 100, 'Boo!']
     524
     525All slice operations return a new list containing the requested elements.  This
     526means that the following slice returns a shallow copy of the list *a*::
     527
     528   >>> a[:]
     529   ['spam', 'eggs', 100, 1234]
    525530
    526531Unlike strings, which are *immutable*, it is possible to change individual
     
    625630
    626631* The *body* of the loop is *indented*: indentation is Python's way of grouping
    627   statements.  Python does not (yet!) provide an intelligent input line editing
    628   facility, so you have to type a tab or space(s) for each indented line.  In
    629   practice you will prepare more complicated input for Python with a text editor;
    630   most text editors have an auto-indent facility.  When a compound statement is
    631   entered interactively, it must be followed by a blank line to indicate
    632   completion (since the parser cannot guess when you have typed the last line).
    633   Note that each line within a basic block must be indented by the same amount.
     632  statements.  At the interactive prompt, you have to type a tab or space(s) for
     633  each indented line.  In practice you will prepare more complicated input
     634  for Python with a text editor; all decent text editors have an auto-indent
     635  facility.  When a compound statement is entered interactively, it must be
     636  followed by a blank line to indicate completion (since the parser cannot
     637  guess when you have typed the last line).  Note that each line within a basic
     638  block must be indented by the same amount.
    634639
    635640* The :keyword:`print` statement writes the value of the expression(s) it is
Note: See TracChangeset for help on using the changeset viewer.