On Sat, Oct 31, 2020 at 21:48 Dan Stromberg firstname.lastname@example.org wrote:
On Sat, Oct 31, 2020 at 9:37 PM Guido van Rossum email@example.com wrote:
I think this over-stresses the notion that users might want to override the comparison operator to be used. We only have two operators that make sense in this context, 'is' and '==', and really, for almost everything you want to do, '==' is the appropriate operator. (There is a small trickle of bugs caused by people inappropriately using e.g. `if x is 1` instead of `if x == 1`, suggesting that if anything, there is too much freedom here.) The big exception is `None`, where you basically always want to use `is`, which is what PEP 634 does.
FWIW, there's an additional exception:
sentinel = object() if var is sentinel:
I use this idiom from time to time - instead of None.
You can just write ‘case sentinel’, since object’s == operator uses identity anyway.