On Thu, Oct 1, 2015 at 12:37 PM, Steven D'Aprano <steve@pearwood.info> wrote:
This makes a difference. Just a few days ago, somebody mis-reported a
supposed "bug" in all() and any(). For example:

values = (x%5 == 3 for x in range(8))
print(all(values))  # should return False

Obvious error is obvious: having printed out the values from the
generator expression, values is now exhausted, and all() of the empty
set is True (vacuous truth). The difference between general iterables
which may or may not be one-shot iterators, and those which are
definitely not iterators, is not always just an implementation detail.

they used a generator expression, when they clearly wanted a list comprehension -- so yes, it matters what they were getting, I don't know that adding more vocabulary would help prevent people from making that mistake...

if they had been smart enough to call the list() again, before claiming there was a bug in all -- it may have explained itself.



Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/


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