Extending: overloading operators (e.g. for a vector class)
Chris Liechti
cliechti at gmx.net
Thu May 23 20:55:31 EDT 2002
Greg Ewing <look at replyto.address.invalid> wrote in
news:3CED82D0.EF5E0C67 at replyto.address.invalid:
> 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.
yes thanks, i hand a look at the sketch sources where this is used in that
way. my extension does work now like expected (yipee).
chris
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list