Jack Diederich wrote:
Since this is 2.4 you could also return a generator expression.


def iter_collapse(myList):

... return (x[0] for (x) in it.groupby([0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5]))
...

But why write a function that returns a generator expression, when you could just turn the function itself into a generator?


Py>def iter_collapse(myList):
...   for x in it.groupby(myList):
...     yield x[0]

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to