Alan Bawden wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > ... >> So I was looking for a predefined object from the standard >> library that already /is/ an iterator (with no need to use >> »iter«). >> >> I found exactly one such object (which can be used after a >> »from ... import ...« statement). Can you guess what it is? > > Well, there's sys.stdin. > > But I would expect beginning students to find the effect of typing > "next(sys.stdin)" to the commnd prompt to be a bit confusing... >
There are a lot of itertools.count() objects, e. g. >>> from multiprocessing.pool import job_counter >>> next(job_counter) 0 >>> next(job_counter) 1 -- https://mail.python.org/mailman/listinfo/python-list