summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-03-07 18:50:55 (GMT)
committerGuido van Rossum <guido@python.org>2006-03-07 18:50:55 (GMT)
commit38fff8c4e4276e4e57660a78f305e68bfa87874b (patch)
tree5f79c06159053f9c7113410fc69dccba01e331ab /Doc
parent9d7855076a8e030e30459de685e762f63bdecac6 (diff)
downloadcpython-38fff8c4e4276e4e57660a78f305e68bfa87874b.zip
cpython-38fff8c4e4276e4e57660a78f305e68bfa87874b.tar.gz
cpython-38fff8c4e4276e4e57660a78f305e68bfa87874b.tar.bz2
Checking in the code for PEP 357.
This was mostly written by Travis Oliphant. I've inspected it all; Neal Norwitz and MvL have also looked at it (in an earlier incarnation).
Diffstat (limited to 'Doc')
-rw-r--r--Doc/api/abstract.tex5
-rw-r--r--Doc/lib/liboperator.tex5
-rw-r--r--Doc/ref/ref3.tex7
3 files changed, 17 insertions, 0 deletions
diff --git a/Doc/api/abstract.tex b/Doc/api/abstract.tex
index c543563..320275c 100644
--- a/Doc/api/abstract.tex
+++ b/Doc/api/abstract.tex
@@ -346,6 +346,7 @@ determination.
either the sequence and mapping protocols, the sequence length is
returned. On error, \code{-1} is returned. This is the equivalent
to the Python expression \samp{len(\var{o})}.\bifuncindex{len}
+ \versionadded{2.5}
\end{cfuncdesc}
@@ -689,6 +690,10 @@ determination.
\samp{float(\var{o})}.\bifuncindex{float}
\end{cfuncdesc}
+\begin{cfuncdesc}{Py_ssize_t}{PyNumber_Index}{PyObject *o}
+ Returns the \var{o} converted to a Py_ssize_t integer on success, or
+ -1 with an exception raised on failure.
+\end{cfuncdesc}
\section{Sequence Protocol \label{sequence}}
diff --git a/Doc/lib/liboperator.tex b/Doc/lib/liboperator.tex
index 11e004a..41da9b7 100644
--- a/Doc/lib/liboperator.tex
+++ b/Doc/lib/liboperator.tex
@@ -171,6 +171,11 @@ effect. This is also known as ``true'' division.
Return the bitwise exclusive or of \var{a} and \var{b}.
\end{funcdesc}
+\begin{funcdesc}{index}{a}
+\funcline{__index__}{a}
+Return \var{a} converted to an integer. Equivalent to \var{a}\code{.__index__()}.
+\versionadded{2.5}
+\end{funcdesc}
Operations which work with sequences include:
diff --git a/Doc/ref/ref3.tex b/Doc/ref/ref3.tex
index 5b78f1c..737b861 100644
--- a/Doc/ref/ref3.tex
+++ b/Doc/ref/ref3.tex
@@ -1978,6 +1978,13 @@ Called to implement the built-in functions
\function{hex()}\bifuncindex{hex}. Should return a string value.
\end{methoddesc}
+\begin{methoddesc}[numeric object]{__index__}{self}
+Called to implement operator.index(). Also called whenever Python
+needs an integer object (such as in slicing). Must return an integer
+(int or long).
+\versionadded{2.5}
+\end{methoddesc}
+
\begin{methoddesc}[numeric object]{__coerce__}{self, other}
Called to implement ``mixed-mode'' numeric arithmetic. Should either
return a 2-tuple containing \var{self} and \var{other} converted to