[issue43786] slice(None) is slice(None) is False

2021-04-09 Thread Nico Schlömer
Nico Schlömer added the comment: Thanks very much, Steven, for the feedback and the suggestion. -- ___ Python tracker ___ ___

[issue43786] slice(None) is slice(None) is False

2021-04-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: The behaviour of `is` is correct. The `is` operator tests for object identity, not equality. The reason that `slice(None) is slice(None)` returns False is that the two calls to the slice function return two different objects. You say that using the equals

[issue43786] slice(None) is slice(None) is False

2021-04-09 Thread Nico Schlömer
New submission from Nico Schlömer : I stumbled upon this when dealing with NumPy arrays: ``` slice(None) is slice(None) ``` ``` False ``` This came up when trying to check if a variable `a` equals `slice(None)`. The comparison ``` a = slice(None) a == slice(None) ``` ``` True ``` works, but