summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2004-11-04 11:29:09 (GMT)
committerArmin Rigo <arigo@tunes.org>2004-11-04 11:29:09 (GMT)
commit80adba6873a9d732108155c26c21a34f373bceb8 (patch)
treeab70ee9748d801407ff52adb061bad9566df1b73
parent99e5ce5cf4c19d908f919825014141b529f238bf (diff)
downloadcpython-80adba6873a9d732108155c26c21a34f373bceb8.zip
cpython-80adba6873a9d732108155c26c21a34f373bceb8.tar.gz
cpython-80adba6873a9d732108155c26c21a34f373bceb8.tar.bz2
Mistakes in the "sequence types" page:
* explanation for example with lists of lists made confusing use of the word "contains" to mean "is built out of". * wrong formula for slices with step. Is it ok to use LaTeX formulas (which become images in the html document)? This version needs one because it's based on a fraction. Just writing "\code{(j-i)/k}" here would be ambiguous because it looks like a rounding-down-to-the-previous-integer division, which is not what we need here. Of course we could write "\code{float(j-i)/k}" but it just looks confusing.
-rw-r--r--Doc/lib/libstdtypes.tex15
1 files changed, 9 insertions, 6 deletions
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index f8eba38..c523d46 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -501,10 +501,11 @@ In Python 2.3 and beyond, \var{x} may be a string of any length.
[[3], [3], [3]]
\end{verbatim}
- What has happened is that \code{lists} is a list containing three
- copies of the list \code{[[]]} (a one-element list containing an
- empty list), but the contained list is shared by each copy. You can
- create a list of different lists this way:
+ What has happened is that \code{[[]]} is a one-element list containing
+ an empty list, so all three elements of \code{[[]] * 3} are (pointers to)
+ this single empty list. Modifying any of the elements of \code{lists}
+ modifies this single list. You can create a list of different lists this
+ way:
\begin{verbatim}
>>> lists = [[] for i in range(3)]
@@ -529,8 +530,10 @@ In Python 2.3 and beyond, \var{x} may be a string of any length.
\item[(5)] The slice of \var{s} from \var{i} to \var{j} with step
\var{k} is defined as the sequence of items with index
- \code{\var{x} = \var{i} + \var{n}*\var{k}} such that \code{0}
- \code{<=} \var{n} \code{<} \code{abs(i-j)}. If \var{i} or \var{j}
+ \code{\var{x} = \var{i} + \var{n}*\var{k}} such that
+ $0 \leq n < \frac{j-i}{k}$. In other words, the indices
+ are \code{i}, \code{i+k}, \code{i+2*k}, \code{i+3*k} and so on, stopping when
+ \var{j} is reached (but never including \var{j}). If \var{i} or \var{j}
is greater than \code{len(\var{s})}, use \code{len(\var{s})}. If
\var{i} or \var{j} are omitted then they become ``end'' values
(which end depends on the sign of \var{k}). Note, \var{k} cannot