harold fellermann wrote:
richcmpfunc compare(PyObject *,PyObject, int);
I supposed the two objects passed are the ones to be compared.
Yes.
What is the meaning of the integer argument? Does it specify the kind
of comparision operator (e.g. __eq__ or __le__), and if so, how?
< 0
<= 1
== 2
!= 3
> 4
>= 5
What is my richcmpfunc supposed to return? 0 or 1 indicating False or
True?
In the usual case, yes, although it can return any
Python object. Rich comparison doesn't impose any
semantics on the operations -- this is one of the
reasons for its existence.
What has to be done, if the function is invoked for an operator
I don't want to define?
Return Py_NotImplemented. (Note that's return, *not* raise.)
Maybe there is some good documentation available, but I cannot find it.
I found most of this out by reading the source, I think.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list