On Thu, Apr 26, 2012 at 10:02 AM, Roy Smith <r...@panix.com> wrote: > I'm not seriously suggesting this as a language addition, just an interesting > idea to simplify some code I'm writing now: > > x = [a for a in iterable while a] > > which equates to: > > x = [] > for a in iterable: > if not a: > break > x.append(a)
Someone borrowed Guido's time machine: http://docs.python.org/library/itertools.html#itertools.takewhile Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list