From 186188d89dc1069f1cfd64811fe8e92f0c9d6774 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 31 Mar 2009 20:56:32 +0000 Subject: #1530012: move TQS section before raw strings. --- Doc/tutorial/introduction.rst | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 99e82a3..21d3627 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -199,21 +199,6 @@ the following:: several lines of text just as you would do in C. Note that whitespace at the beginning of the line is significant. -If we make the string literal a "raw" string, however, the ``\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:: - - hello = r"This is a rather long string containing\n\ - several lines of text much as you would do in C." - - print hello - -would print:: - - This is a rather long string containing\n\ - several lines of text much as you would do in C. - 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. :: @@ -230,6 +215,20 @@ produces the following output:: -h Display this usage message -H hostname Hostname to connect to +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:: + + hello = r"This is a rather long string containing\n\ + several lines of text much as you would do in C." + + print hello + +would print:: + + This is a rather long string containing\n\ + several lines of text much as you would do in C. + 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 -- cgit v0.12