Expression can be simplified on list

MRAB python at mrabarnett.plus.com
Thu Sep 29 12:36:55 EDT 2016


On 2016-09-29 16:56, Steve D'Aprano wrote:
> On Thu, 29 Sep 2016 09:53 pm, MRAB wrote:
>
>> What if an _exhausted_ iterator was falsey?
>
>
> The problem is that in general you can't tell if an iterator is exhausted
> until you attempt to advance it. So even if bool(iterator) returns True,
> the call to next() may raise StopIteration:
>
[snip]

By "exhausted" I meant "has previously raised StopIteration".




More information about the Python-list mailing list