Operator commutativity

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Sep 19 21:22:41 EDT 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