summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/datastructures.rst12
-rw-r--r--Doc/tutorial/introduction.rst29
2 files changed, 14 insertions, 27 deletions
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index f5a464b..02b08d9 100644
--- a/Doc/tutorial/datastructures.rst
+++ b/Doc/tutorial/datastructures.rst
@@ -347,13 +347,11 @@ The reverse operation is also possible::
>>> x, y, z = t
-This is called, appropriately enough, *sequence unpacking*. Sequence unpacking
-requires the list of variables on the left to have the same number of elements
-as the length of the sequence. Note that multiple assignment is really just a
-combination of tuple packing and sequence unpacking!
-
-There is a small bit of asymmetry here: packing multiple values always creates
-a tuple, and unpacking works for any sequence.
+This is called, appropriately enough, *sequence unpacking* and works for any
+sequence on the right-hand side. Sequence unpacking requires the list of
+variables on the left to have the same number of elements as the length of the
+sequence. Note that multiple assignment is really just a combination of tuple
+packing and sequence unpacking.
.. XXX Add a bit on the difference between tuples and lists.
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index 10166a6..c0f4156 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -225,10 +225,9 @@ 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::
+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."
@@ -240,22 +239,12 @@ 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. ::
-
- print("""
- Usage: thingy [OPTIONS]
- -h Display this usage message
- -H hostname Hostname to connect to
- """)
-
-produces the following output::
-
- Usage: thingy [OPTIONS]
- -h Display this usage message
- -H hostname Hostname to connect to
-
+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
+double quotes if the string contains a single quote and no double quotes, else
+it's enclosed in single quotes. (The :func:`print` function, described later,
+can be used to write strings without quotes or escapes.)
Strings can be concatenated (glued together) with the ``+`` operator, and
repeated with ``*``::