Vladimir

55%
Flag icon
If an infix operator method raises an exception, it aborts the operator dispatch algorithm. In the particular case of TypeError, it is often better to catch it and return NotImplemented. This allows the interpreter to try calling the reversed operator method, which may correctly handle the computation with the swapped operands, if they are of different types.
Fluent Python: Clear, Concise, and Effective Programming
Rate this book
Clear rating
Open Preview