[Numpy-discussion] Why are empty arrays False?
chris.barker at noaa.gov
Tue Aug 22 17:48:14 EDT 2017
On Tue, Aug 22, 2017 at 11:04 AM, Michael Lamparski <
diagonaldevice at gmail.com> wrote:
> I think truthiness is easily a wart in any dynamically-typed language (and
> yet ironically, every language I can think of that has truthiness is
> dynamically typed except for C++). And yet for some reason it seems to be
> pressed forward as idiomatic in python, and for that reason alone, I use
me too :-)
> Meanwhile, for an arbitrary iterator taken as an argument, if you want it
> to have at least one element for some reason, then good luck; truthiness
> will not help you.
of course, nor will len()
And this is mostly OK, as if you are taking an aritrary iterable, then you
are probably going to, well, iterate over it, and:
for this in an_empty_iterable:
But bringing it back OT -- it's all a bit messy, but there is logic for
the existing conventions in numpy -- and I think backward compatibility is
more important than a slightly cleaner API.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion