Changeset 391 for python/trunk/Doc/tutorial/introduction.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/introduction.rst
r2 r391 83 83 error will occur:: 84 84 85 >>> # try to access an undefined variable 86 ... n 85 >>> n # try to access an undefined variable 87 86 Traceback (most recent call last): 88 87 File "<stdin>", line 1, in <module> … … 179 178 '"Isn\'t," she said.' 180 179 180 The interpreter prints the result of string operations in the same way as they 181 are typed for input: inside quotes, and with quotes and other funny characters 182 escaped by backslashes, to show the precise value. The string is enclosed in 183 double quotes if the string contains a single quote and no double quotes, else 184 it's enclosed in single quotes. The :keyword:`print` statement produces a more 185 readable output for such input strings. 186 181 187 String literals can span multiple lines in several ways. Continuation lines can 182 188 be used, with a backslash as the last character on the line indicating that the … … 190 196 print hello 191 197 192 Note that newlines still need to be embedded in the string using ``\n`` ;the198 Note that newlines still need to be embedded in the string using ``\n`` -- the 193 199 newline following the trailing backslash is discarded. This example would print 194 200 the following: … … 233 239 This is a rather long string containing\n\ 234 240 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 they237 are typed for input: inside quotes, and with quotes and other funny characters238 escaped by backslashes, to show the precise value. The string is enclosed in239 double quotes if the string contains a single quote and no double quotes, else240 it's enclosed in single quotes. (The :keyword:`print` statement, described241 later, can be used to write strings without quotes or escapes.)242 241 243 242 Strings can be concatenated (glued together) with the ``+`` operator, and … … 523 522 >>> 3*a[:3] + ['Boo!'] 524 523 ['spam', 'eggs', 100, 'spam', 'eggs', 100, 'spam', 'eggs', 100, 'Boo!'] 524 525 All slice operations return a new list containing the requested elements. This 526 means that the following slice returns a shallow copy of the list *a*:: 527 528 >>> a[:] 529 ['spam', 'eggs', 100, 1234] 525 530 526 531 Unlike strings, which are *immutable*, it is possible to change individual … … 625 630 626 631 * 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 editing628 facility, so you have to type a tab or space(s) for each indented line. In629 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 is631 entered interactively, it must be followed by a blank line to indicate632 completion (since the parser cannot guess when you have typed the last line).633 Note that each line within a basicblock 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. 634 639 635 640 * The :keyword:`print` statement writes the value of the expression(s) it is
Note:
See TracChangeset
for help on using the changeset viewer.