Operator commutativity

Henrik Faber hfaber at invalid.net
Mon Sep 19 13:32:00 CEST 2011

On 19.09.2011 13:23, Paul Rudin wrote:
> Henrik Faber <hfaber at invalid.net> writes:
>> How can I make this commutative?
> Incidentally - this isn't really about commutativity at all - the
> question is how can you define both left and right versions of add,
> irrespective of whether they yield the same result.

Right. The operator+ in my case just happens to be commutative and I
wanted a language way to express this.

> I think __radd__ is what you're after.

It is, thank you very much - I knew there was some way to get this done
nicely. Perfect! :-)

Best regards,

More information about the Python-list mailing list