Extending: overloading operators (e.g. for a vector class)
Greg Ewing
look at replyto.address.invalid
Thu May 23 20:01:20 EDT 2002
Chris Liechti wrote:
>
> can you give me a hint where such thing as the NEW_STYLE_NUMBER flags are
> documented?
I don't know. It might not be documented anywhere yet --
this is all fairly new stuff.
By the way, there's one difference I should perhaps have
mentioned between the Python and C versions of operator
overloading -- in C there are no separate "reversed"
versions of the operator methods. For example, if
you do x*y and x doesn't have an nb_multiply method,
then y.nb_multiply(x, y) is done.
So, you have to be prepared for the second operand
being "self" instead of the first one, if you see
what I mean.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list