On Wed, 11 Mar 2020 at 18:08, Serhiy Storchaka <storch...@gmail.com> wrote:
> There is a precedence (although not in the stdlib):  NumPy array with
> dtype=bool.
>
>   >>> import numpy
>   >>> bool(numpy.array([False, False]))
>   Traceback (most recent call last):
>     File "<stdin>", line 1, in <module>
>   ValueError: The truth value of an array with more than one element is
> ambiguous. Use a.any() or a.all()

Actually, this is the behaviour of ndarray with any dtype. And IMHO
ithis is quite.... terrible?
I was so used to have False for an empty iterable that ndarray
surprised me. I had to add a boolean() function in my little msutils
module, that works also for ndarrays.
And the reason ndarray do this is because it also override __eq__():
https://github.com/numpy/numpy/issues/15573
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GVTHHQZ6USSQVUI3IM7KU42TKWS4ITFY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to