Index: tutorial/introduction.rst =================================================================== --- tutorial/introduction.rst (revision 74631) +++ tutorial/introduction.rst (working copy) @@ -138,7 +138,6 @@ 4.0 >>> abs(a) # sqrt(a.real**2 + a.imag**2) 5.0 - >>> In interactive mode, the last printed expression is assigned to the variable ``_``. This means that when you are using Python as a desk calculator, it is @@ -152,7 +151,6 @@ 113.0625 >>> round(_, 2) 113.06 - >>> This variable should be treated as read-only by the user. Don't explicitly assign a value to it --- you would create an independent local variable with the @@ -191,6 +189,8 @@ print hello +.. highlightlang:: none + Note that newlines still need to be embedded in the string using ``\n``; the newline following the trailing backslash is discarded. This example would print the following:: @@ -199,6 +199,8 @@ several lines of text just as you would do in C. Note that whitespace at the beginning of the line is significant. +.. highlightlang:: python + Or, strings can be surrounded in a pair of matching triple-quotes: ``"""`` or ``'''``. End of lines do not need to be escaped when using triple-quotes, but they will be included in the string. :: @@ -209,12 +211,16 @@ -H hostname Hostname to connect to """ +.. highlightlang:: none + produces the following output:: Usage: thingy [OPTIONS] -h Display this usage message -H hostname Hostname to connect to +.. highlightlang:: python + If we make the string literal a "raw" string, ``\n`` sequences are not converted to newlines, but the backslash at the end of the line, and the newline character in the source, are both included in the string as data. Thus, the example:: @@ -224,11 +230,15 @@ print hello +.. highlightlang:: none + would print:: This is a rather long string containing\n\ several lines of text much as you would do in C. +.. highlightlang:: python + The interpreter prints the result of string operations in the same way as they are typed for input: inside quotes, and with quotes and other funny characters escaped by backslashes, to show the precise value. The string is enclosed in