Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes: > I've never seen this second form in actual code. Does anyone use it, > and if so, what use-cases do you have?
Since APIs that signal end-of-iteration by returning a sentinel have fallen out of favor in Python (with good reason), this form is rare, but still it's sometimes useful. I've used it in actual code for reading a file in fixed-size chunks, like this: for chunk in iter(lambda: f.read(CHUNK_SIZE), ''): ... -- http://mail.python.org/mailman/listinfo/python-list