Message251818
You wholly consume the iterator after the first time you apply `list()` to it. Therefore both `any()` and `all()` see an empty iterator, and return the results appropriate for an empty sequence:
>>> multiples_of_6 = (not (i % 6) for i in range(1, 10))
>>> list(multiples_of_6)
[False, False, False, False, False, True, False, False, False]
>>> list(multiples_of_6) # note: the iterator is exhausted!
[]
>>> any([])
False
>>> all([])
True |
|
Date |
User |
Action |
Args |
2015-09-29 04:12:57 | tim.peters | set | recipients:
+ tim.peters, steven.daprano, Sreenivasulu Saya |
2015-09-29 04:12:56 | tim.peters | set | messageid: <1443499976.98.0.41772616826.issue25261@psf.upfronthosting.co.za> |
2015-09-29 04:12:56 | tim.peters | link | issue25261 messages |
2015-09-29 04:12:56 | tim.peters | create | |
|