
On Mon, Aug 30, 2021, 15:38 Nick Parlante <nick@cs.stanford.edu> wrote:
Hi Chris - thanks for the response,
so here you say:
I disagree; experienced programmers should be using "is" where it's
correct.
I think PEP8 has forced people to use "is" so much, they've lost touch with the reality that in fact == would work perfectly in almost all cases. Situations where "is" is required for correctness are very rare.
For you. For me, x==None failing is by far the most common scenario. That is because I do a lot of numeric programming and the only place I am likely to test for None is when setting a default input for a mutable value, which is an array-like most of the time. And numeric programming is one of the most common python use-cases so it isn't like that can just be ignored. And it isn't just numeric programming. There is an enormous number of different ways == is modified. But you can't change "is" in any reasonably simple way. The great thing about python duck-typing is that you often don't need to care about what your inputs are. But it also means you shouldn't make your code needlessly brittle so it only works properly with a handful of stdlib types.