Steven D'Aprano <[email protected]> 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 operator `==` "doesn't return a single Boolean if
a is a NumPy array", that is a design flaw in numpy, and there is nothing we
can do about it.
You could try something like this:
def equal(a, b):
flag = (a == b)
if isinstance(flag, bool):
return flag
else:
return all(flag)
----------
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43786>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com