Message230405
| Author |
ethan.furman |
| Recipients |
Joshua.Chin, ethan.furman, pitrou, r.david.murray, rhettinger |
| Date |
2014年10月31日.22:31:20 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1414794680.98.0.595971074307.issue22766@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
https://docs.python.org/2/reference/datamodel.html#object.__iadd__
------------------------------------------------------------------
[...] These methods should attempt to do the operation in-place (modifying self) and return the result (which could be, but does not have to be, self). If a specific method is not defined, the augmented assignment falls back to the normal methods. For instance, to execute the statement x += y, where x is an instance of a class that has an __iadd__() method, x.__iadd__(y) is called. If x is an instance of a class that does not define a __iadd__() method, x.__add__(y) and y.__radd__(x) are considered, as with the evaluation of x + y.
-------------------------------------------------------------------
Returning NotImplemented still allows a TypeError to be raised, is subclass friendly, and is the way Python is designed. |
|