3 ms·
Did you get far past the first example? Because a lot of these seem just plain unacceptable.. How about this from the second example: >>> a, b = "wtf!", "w
by ktm5j 7y ago
Did you get far past the first example? Because a lot of these seem just plain unacceptable..
How about this from the second example:
>>> a, b = "wtf!", "wtf!"
>>> a is b # All versions except 3.7.x
True
>>> a = "wtf!"; b = "wtf!"
>>> a is b # This will print True or False depending on where you're invoking it (python shell / ipython / as a script)
False
Or this from further down
>>> a = 256
>>> b = 256
>>> a is b
True
>>> a = 257
>>> b = 257
>>> a is b
False
- kevincox 7y agoI agree. I wonder how confusing it would be to make `is` not allowed on integers or strings. Or define it to be equivalent to `==` for those types. Using `is` in these situations is almost always a big, if for whatever reason you really need it you can do `objectid(x) == objectid(y)` which is usefully explicitly.