[docs] [issue12067] Doc: remove errors about mixed-type comparisons.
Mark Dickinson
report at bugs.python.org
Sat Sep 22 10:17:00 CEST 2012
Mark Dickinson added the comment:
> I determined that 'raise TypeError' and 'return NotImplemented' both
> result in the call of the reflected method
Are you sure? raise TypeError *should* result in the operation being abandoned, with the reflected operation not tried.
Python 3.3.0rc2+ (default:3504cbb3e1d8, Sep 20 2012, 22:08:44)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class A:
... def __add__(self, other):
... raise TypeError("Don't know how to add")
... def __le__(self, other):
... raise TypeError("Can't compare")
...
[65945 refs]
>>> class B:
... def __radd__(self, other):
... return 42
... def __ge__(self, other):
... return False
...
[66016 refs]
>>> A() <= B()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in __le__
TypeError: Can't compare
[66064 refs]
>>> A() + B()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __add__
TypeError: Don't know how to add
[66065 refs]
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12067>
_______________________________________
More information about the docs
mailing list