Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e51aa5b

Browse files
committed
Minor clarifications by Sean Reifschneider:
- add example of string literal concatenation - add clarifying comment to the example of the if statement
1 parent 87e611e commit e51aa5b

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Doc/tut/tut.tex

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,20 @@ \subsection{Strings \label{strings}}
549549

550550
Two string literals next to each other are automatically concatenated;
551551
the first line above could also have been written \samp{word = 'Help'
552-
'A'}; this only works with two literals, not with arbitrary string expressions.
552+
'A'}; this only works with two literals, not with arbitrary string
553+
expressions:
554+
555+
\begin{verbatim}
556+
>>> 'str' 'ing' # <- This is ok
557+
'string'
558+
>>> string.strip('str') + 'ing' # <- This is ok
559+
'string'
560+
>>> string.strip('str') 'ing' # <- This is invalid
561+
File "<stdin>", line 1
562+
string.strip('str') 'ing'
563+
^
564+
SyntaxError: invalid syntax
565+
\end{verbatim}
553566

554567
Strings can be subscripted (indexed); like in \C{}, the first character
555568
of a string has subscript (index) 0. There is no separate character
@@ -853,6 +866,7 @@ \section{\keyword{if} Statements \label{if}}
853866
statement. For example:
854867

855868
\begin{verbatim}
869+
>>> # [Code which sets 'x' to a value...]
856870
>>> if x < 0:
857871
... x = 0
858872
... print 'Negative changed to zero'

0 commit comments

Comments
 (0)