Kaydet (Commit) e51aa5b2 authored tarafından Guido van Rossum's avatar Guido van Rossum

Minor clarifications by Sean Reifschneider:

- add example of string literal concatenation
- add clarifying comment to the example of the if statement
üst 87e611e4
...@@ -549,7 +549,20 @@ operator, and repeated with \code{*}: ...@@ -549,7 +549,20 @@ operator, and repeated with \code{*}:
Two string literals next to each other are automatically concatenated; Two string literals next to each other are automatically concatenated;
the first line above could also have been written \samp{word = 'Help' 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 Strings can be subscripted (indexed); like in \C{}, the first character
of a string has subscript (index) 0. There is no separate 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} ...@@ -853,6 +866,7 @@ Perhaps the most well-known statement type is the \keyword{if}
statement. For example: statement. For example:
\begin{verbatim} \begin{verbatim}
>>> # [Code which sets 'x' to a value...]
>>> if x < 0: >>> if x < 0:
... x = 0 ... x = 0
... print 'Negative changed to zero' ... print 'Negative changed to zero'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment