On Mon, Nov 14, 2016 at 8:57 AM, Gregory Ewing
<greg.ew...@canterbury.ac.nz> wrote:
> Antoon Pardon wrote:
>
>> def bar(iterator):
>>     if iter(iterator) is iterator:
>>         ...
>
>
> That's a way of finding out whether you can safely iterate
> over something more than once. If the object is already an
> iterator, applying iter() to it will return the same
> object, and iterating over it will consume it.

Not strictly true. There's no guarantee that something that yields new
iterators is actually reiterable. And even if it is, there's no
guarantee that it'll yield the same values.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to