1 Mar 2005 05:36
[ python-Bugs-1153163 ] reflected operator not used when operands have the same type
SourceForge.net <noreply <at> sourceforge.net>
2005-03-01 04:36:13 GMT
2005-03-01 04:36:13 GMT
Bugs item #1153163, was opened at 2005-02-27 20:09 Message generated for change (Comment added) made by hughsw You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1153163&group_id=5470 Category: Python Interpreter Core Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Hugh Secker-Walker (hughsw) Assigned to: Nobody/Anonymous (nobody) Summary: reflected operator not used when operands have the same type Initial Comment: The reflected operators, e.g. __radd__, are used when the left operand does not have the non-reflected operator, *unless* the right operand is of the same type. The documentation on the "Emulating numeric types" page doesn't mention this peculiar exclusion. Of the reflected operators it says: "These methods are called to implement the binary arithmetic operations (+, -, *, /, %, divmod(), pow(), **, <<, >>, &, ^, |) with reflected (swapped) operands. These functions are only called if the left operand does not support the corresponding operation. For instance, to evaluate the expression x-y, where y is an instance of a class that has an __rsub__() method,(Continue reading)
RSS Feed