DanielStutzbach/blist — Issue #37: btuple raises TypeError instead of returning NotImplemented
Author: ozomer
Created: 2011-10-30 20:33:42+00:00
State: open

I want to add some functionality using __radd__ .

class MyClass(object):
def __radd__(self, other):
return 7

If I create a new MyClass object and get:

>>> c = Coo()
>>> () + Coo()
7
>>> [] + Coo()
7
>>> blist.blist() + Coo()
7
>>> blist.btuple() + Coo()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.6/dist-packages/blist-1.3.4-py2.6-linux-i686.egg/_btuple.py", line 47, in __add__
raise TypeError
TypeError

This happens because the \_\_add\_\_ function returns raises _TypeError_ instead of returning _NotImplemeted_, so the other object's \_\_radd\_\_ is not called.