<[EMAIL PROTECTED]> wrote: >Bengt Richter 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 ?
<http://docs.python.org/lib/built-in-funcs.html>: iter(o, sentinel) [ ... ] The iterator created in this case will call o with no arguments for each call to its next() method; if the value returned is equal to sentinel, StopIteration will be raised, otherwise the value will be returned. In this case, o is: lambda b=[2]:b.append(b[0]**2) or b[0]<1000 and b.pop(0) or None which returns None when b[0]>=1000 (None or (False and _) or None evaluates to the last None). -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ | -- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- http://mail.python.org/mailman/listinfo/python-list