Message333433
> the canonical __ne__ delegation to __eq__ for any class should be implemented as something like
I disagree that your code snippet is the canonical way to write __ne__. I'd write it like this:
def __ne__(self, other):
return not (self == other)
Or just not write it at all. Python will automatically call __eq__ going back to Python 2.4 (and possibly older).
Delegating to __eq__ directly is the wrong way to do it.
> NotImplemented is a sentinel value that should never be evaluated in a boolean context
I don't see why not. I can't think of any use-cases where I would want to *specifically* use NotImplemented in a boolean context, but I see no good reason why I would want it to fail if one happened to do so. |
|
Date |
User |
Action |
Args |
2019-01-11 01:44:02 | steven.daprano | set | recipients:
+ steven.daprano, josh.r, xtreak |
2019-01-11 01:44:01 | steven.daprano | set | messageid: <1547171041.41.0.673000572335.issue35712@roundup.psfhosted.org> |
2019-01-11 01:44:01 | steven.daprano | link | issue35712 messages |
2019-01-11 01:44:01 | steven.daprano | create | |
|