if iter(iterator) is iterator

Antoon Pardon antoon.pardon at rece.vub.ac.be
Sun Nov 13 15:02:33 EST 2016


Some time ago I read a text or saw a video on iterators and one thing
I remember from it, is that you should do something like the following
when working with iterators, to avoid some pitt falls.

def bar(iterator):
    if iter(iterator) is iterator:
        ...

However I can't relocate it and can't remember the what and how anymore.
Does anyone know what this is about?

-- 
Antoon.



More information about the Python-list mailing list