Sequence indexes are non-negative, not natural (0 is not a natural number).

Reported by Daniel May <mayds@ecn.purdue.edu>.

De-tabified everywhere.
This commit is contained in:
Fred Drake 2001-02-22 21:28:04 +00:00
parent 7c30de65f4
commit 230d17d0d1

View file

@ -227,7 +227,7 @@ and \code{z.imag}.
\end{description} % Numbers \end{description} % Numbers
\item[Sequences] \item[Sequences]
These represent finite ordered sets indexed by natural numbers. These represent finite ordered sets indexed by non-negative numbers.
The built-in function \function{len()}\bifuncindex{len} returns the The built-in function \function{len()}\bifuncindex{len} returns the
number of items of a sequence. number of items of a sequence.
When the length of a sequence is \var{n}, the When the length of a sequence is \var{n}, the
@ -1416,55 +1416,55 @@ skipped.
\item[1.] If \var{x} is a class instance: \item[1.] If \var{x} is a class instance:
\begin{itemize} \begin{itemize}
\item[1a.] If \var{x} has a \method{__coerce__()} method: \item[1a.] If \var{x} has a \method{__coerce__()} method:
replace \var{x} and \var{y} with the 2-tuple returned by replace \var{x} and \var{y} with the 2-tuple returned by
\code{\var{x}.__coerce__(\var{y})}; skip to step 2 if the \code{\var{x}.__coerce__(\var{y})}; skip to step 2 if the
coercion returns \code{None}. coercion returns \code{None}.
\item[1b.] If neither \var{x} nor \var{y} is a class instance \item[1b.] If neither \var{x} nor \var{y} is a class instance
after coercion, go to step 3. after coercion, go to step 3.
\item[1c.] If \var{x} has a method \method{__op__()}, return \item[1c.] If \var{x} has a method \method{__op__()}, return
\code{\var{x}.__op__(\var{y})}; otherwise, restore \var{x} and \code{\var{x}.__op__(\var{y})}; otherwise, restore \var{x} and
\var{y} to their value before step 1a. \var{y} to their value before step 1a.
\end{itemize} \end{itemize}
\item[2.] If \var{y} is a class instance: \item[2.] If \var{y} is a class instance:
\begin{itemize} \begin{itemize}
\item[2a.] If \var{y} has a \method{__coerce__()} method: \item[2a.] If \var{y} has a \method{__coerce__()} method:
replace \var{y} and \var{x} with the 2-tuple returned by replace \var{y} and \var{x} with the 2-tuple returned by
\code{\var{y}.__coerce__(\var{x})}; skip to step 3 if the \code{\var{y}.__coerce__(\var{x})}; skip to step 3 if the
coercion returns \code{None}. coercion returns \code{None}.
\item[2b.] If neither \var{x} nor \var{y} is a class instance \item[2b.] If neither \var{x} nor \var{y} is a class instance
after coercion, go to step 3. after coercion, go to step 3.
\item[2b.] If \var{y} has a method \method{__rop__()}, return \item[2b.] If \var{y} has a method \method{__rop__()}, return
\code{\var{y}.__rop__(\var{x})}; otherwise, restore \var{x} \code{\var{y}.__rop__(\var{x})}; otherwise, restore \var{x}
and \var{y} to their value before step 2a. and \var{y} to their value before step 2a.
\end{itemize} \end{itemize}
\item[3.] We only get here if neither \var{x} nor \var{y} is a class \item[3.] We only get here if neither \var{x} nor \var{y} is a class
instance. instance.
\begin{itemize} \begin{itemize}
\item[3a.] If op is `\code{+}' and \var{x} is a sequence, \item[3a.] If op is `\code{+}' and \var{x} is a sequence,
sequence concatenation is invoked. sequence concatenation is invoked.
\item[3b.] If op is `\code{*}' and one operand is a sequence \item[3b.] If op is `\code{*}' and one operand is a sequence
and the other an integer, sequence repetition is invoked. and the other an integer, sequence repetition is invoked.
\item[3c.] Otherwise, both operands must be numbers; they are \item[3c.] Otherwise, both operands must be numbers; they are
coerced to a common type if possible, and the numeric coerced to a common type if possible, and the numeric
operation is invoked for that type. operation is invoked for that type.
\end{itemize} \end{itemize}
\end{itemize} \end{itemize}