On Jul 25, 3:26 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > Speaking of the iter builtin function, is there an example of the > use of the optional sentinel object somewhere I could see?
# iterate over random numbers from 1 to 10; use 0 as a sentinel to stop the iteration for n in iter(lambda:random.randrange(10), 0): print n More generally, iter(callable, sentinel) is just a convenience function for the following generator: def iter(callable, sentinel): while True: c = callable() if c == sentinel: break yield c George -- http://mail.python.org/mailman/listinfo/python-list