>>> class D:
... @property
... def __add__(self):
... raise AttributeError('Not so fast, pardner!')
...
>>> D() + D()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in __add__
AttributeError: Not so fast, pardner!
On 04/18, Ionel Cristian Mărieș wrote:
> __add__ as a property/descriptor seems to work fine, eg:
>
> >>> class C:
> > ... @property
> > ... def __add__(self):
> > ... return lambda other: [self, other]
> > ...
> > >>> C() + C()
> > [<__main__.C object at 0x0000000003652AC8>, <__main__.C object at
> > 0x0000000003652CC0>]
> >
>
> Am I missing something?
What happens when your __add__ raises an AttributeError?
--
~Ethan~
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/