[email protected] wrote:
> def __richcmp__(self, A other, int op):
> print "using op: ",op
> if op == 2: # ==
> return self.a == other.a
It's also not really a good idea to put type declarations
into the parameter list when defining operator methods.
That's because it will result in a TypeError when called
with mismatched types, whereas the correct thing to do is
to *return* (not raise) NotImplemented, so that the
interpreter will try other ways of handling the operation.
It's better to do something like this:
def __richcmp__(self, other, int op):
if isinstance(self, A) and isinstance(other, A):
# handle these types of operands
else:
return NotImplemented
--
Greg
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev