summaryrefslogtreecommitdiffstats
path: root/Doc/tut
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-01-06 23:14:14 (GMT)
committerGuido van Rossum <guido@python.org>1999-01-06 23:14:14 (GMT)
commite51aa5b2cd537c2253c908bccd47e58bc195796b (patch)
tree9a0a7205907d6188ad30a2df0e01592fb529b16b /Doc/tut
parent87e611e4416d6e56ea54b22cddb689bef2d4bebd (diff)
downloadcpython-e51aa5b2cd537c2253c908bccd47e58bc195796b.zip
cpython-e51aa5b2cd537c2253c908bccd47e58bc195796b.tar.gz
cpython-e51aa5b2cd537c2253c908bccd47e58bc195796b.tar.bz2
Minor clarifications by Sean Reifschneider:
- add example of string literal concatenation - add clarifying comment to the example of the if statement
Diffstat (limited to 'Doc/tut')
-rw-r--r--Doc/tut/tut.tex16
1 files changed, 15 insertions, 1 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex
index dc59074..f647aed 100644
--- a/Doc/tut/tut.tex
+++ b/Doc/tut/tut.tex
@@ -549,7 +549,20 @@ operator, and repeated with \code{*}:
Two string literals next to each other are automatically concatenated;
the first line above could also have been written \samp{word = 'Help'
-'A'}; this only works with two literals, not with arbitrary string expressions.
+'A'}; this only works with two literals, not with arbitrary string
+expressions:
+
+\begin{verbatim}
+>>> 'str' 'ing' # <- This is ok
+'string'
+>>> string.strip('str') + 'ing' # <- This is ok
+'string'
+>>> string.strip('str') 'ing' # <- This is invalid
+ File "<stdin>", line 1
+ string.strip('str') 'ing'
+ ^
+SyntaxError: invalid syntax
+\end{verbatim}
Strings can be subscripted (indexed); like in \C{}, the first character
of a string has subscript (index) 0. There is no separate character
@@ -853,6 +866,7 @@ Perhaps the most well-known statement type is the \keyword{if}
statement. For example:
\begin{verbatim}
+>>> # [Code which sets 'x' to a value...]
>>> if x < 0:
... x = 0
... print 'Negative changed to zero'