summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-04-14 20:58:14 (GMT)
committerGuido van Rossum <guido@python.org>2003-04-14 20:58:14 (GMT)
commit3a3cca5b820084d759b06aed84b1070a56786af5 (patch)
tree81809e367df89b0dbb4255be3316b7083ca31e45 /Doc
parentb43f15e1ce34deac45eb173db5f12d3d979cf08e (diff)
downloadcpython-3a3cca5b820084d759b06aed84b1070a56786af5.zip
cpython-3a3cca5b820084d759b06aed84b1070a56786af5.tar.gz
cpython-3a3cca5b820084d759b06aed84b1070a56786af5.tar.bz2
- list.insert(i, x) now interprets negative i as it would be
interpreted by slicing, so negative values count from the end of the list. This was the only place where such an interpretation was not placed on a list index.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libstdtypes.tex9
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index 469b9d3..f9e6566 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -941,8 +941,7 @@ The following operations are defined on mutable sequence types (where
\lineiii{\var{s}.index(\var{x})}
{return smallest \var{i} such that \code{\var{s}[\var{i}] == \var{x}}}{(4)}
\lineiii{\var{s}.insert(\var{i}, \var{x})}
- {same as \code{\var{s}[\var{i}:\var{i}] = [\var{x}]}
- if \code{\var{i} >= 0}}{(5)}
+ {same as \code{\var{s}[\var{i}:\var{i}] = [\var{x}]}}{(5)}
\lineiii{\var{s}.pop(\optional{\var{i}})}
{same as \code{\var{x} = \var{s}[\var{i}]; del \var{s}[\var{i}]; return \var{x}}}{(6)}
\lineiii{\var{s}.remove(\var{x})}
@@ -982,8 +981,10 @@ Notes:
\var{s}.
\item[(5)] When a negative index is passed as the first parameter to
- the \method{insert()} method, the new element is prepended to the
- sequence.
+ the \method{insert()} method, the list length is added, as for slice
+ indices. If it is still negative, it is truncated to zero, as for
+ slice indices. \versionchanged[Previously, all negative indices
+ were truncated to zero]{2.3}
\item[(6)] The \method{pop()} method is only supported by the list and
array types. The optional argument \var{i} defaults to \code{-1},