[Python-ideas] [Python-ideos] Dedicated overloadable boolean operators
Chris Barker - NOAA Federal
chris.barker at noaa.gov
Wed Nov 25 11:00:37 EST 2015
> What does it _matter_ that you get True (or 1, etc) instead of
> [True, True, True, True, True, True]?
Sometimes you want to know that everything in an array is True ( which
is common enough that numpy.alltrue() exists)
But other times you want to know which items in an array a true, and
which are not -- most often to use as a Boolean mask -- in which case,
an array that happens to have all true values is a different beast
altogether from a single True. And remember that thee could be arrays
of any number of dimensions.
Also: Python Truthyness rules define an empty container as False, and
any non-empty container as True -- it's probably better not to make
arrays unique in that regard.
-CHB
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas
mailing list