Operator commutativity

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Sep 20 03:22:41 CEST 2011


Westley Martínez wrote:

> def __radd__(self, other):
>     return self.__add__(self, other)

Which, inside a class, can be simplified to:

    __radd__ = __add__



-- 
Steven




More information about the Python-list mailing list