[EMAIL PROTECTED] wrote:
>>>>> list(iter(lambda b=[2]:b.append(b[0]**2) or b[0]<1000 and b.pop(0) or
>>None, None)) [2, 4, 16, 256]
>>
> out of curiosity, what stops the iterator ?
"""
Help on built-in function iter in module __builtin__:
iter(...)
iter(collection) -> iterator
iter(callable, sentinel) -> iterator
Get an iterator from an object. In the first form, the argument must
supply its own iterator, or be a sequence.
In the second form, the callable is called until it returns the
sentinel.
"""
The lambda is used as the callable, None as the sentinel.
Peter
--
http://mail.python.org/mailman/listinfo/python-list