[Python-checkins] python/dist/src/Doc/tut tut.tex,1.177,1.178
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Tue, 11 Mar 2003 20:46:54 -0800
Update of /cvsroot/python/python/dist/src/Doc/tut
In directory sc8-pr-cvs1:/tmp/cvs-serv10667
Modified Files:
tut.tex
Log Message:
SF bug #699237: Tutorial uses omitted slice indices before explaining them
Moved up the explanation of slice default arguments.
Index: tut.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.177
retrieving revision 1.178
diff -C2 -d -r1.177 -r1.178
*** tut.tex 1 Mar 2003 03:20:39 -0000 1.177
--- tut.tex 12 Mar 2003 04:46:52 -0000 1.178
***************
*** 641,644 ****
--- 641,655 ----
\end{verbatim}
+ Slice indices have useful defaults; an omitted first index defaults to
+ zero, an omitted second index defaults to the size of the string being
+ sliced.
+
+ \begin{verbatim}
+ >>> word[:2] # The first two characters
+ 'He'
+ >>> word[2:] # All but the first two characters
+ 'lpA'
+ \end{verbatim}
+
Unlike a C string, Python strings cannot be changed. Assigning to an
indexed position in the string results in an error:
***************
*** 663,677 ****
>>> 'Splat' + word[4]
'SplatA'
- \end{verbatim}
-
- Slice indices have useful defaults; an omitted first index defaults to
- zero, an omitted second index defaults to the size of the string being
- sliced.
-
- \begin{verbatim}
- >>> word[:2] # The first two characters
- 'He'
- >>> word[2:] # All but the first two characters
- 'lpA'
\end{verbatim}
--- 674,677 ----