Steve R. Hastings wrote: > We could also use "generator expressions", available only in > Python 2.4 and newer. > > A list comprehension always builds a list. A generator expression can > return values one at a time. > > [v for v in seq if v] # builds a list and returns it > (v for v in seq if v) # returns a generator object
Woah, interesting. Somehow I don't think I knew that generators could exist outside of generator functions (using yield)! I was wondering why the second one above worked without brackets. :) -- http://mail.python.org/mailman/listinfo/python-list