Big time WTF with generators - bug?

Paul Rubin http
Wed Feb 13 04:42:17 EST 2008


Peter Otten <__peter__ at web.de> writes:
> >    for s_name, series in serialized:
> >      grouped = groupby(series, keyfunc)
> >      regrouped = ((k, (v[1] for v in g)) for (k,g) in grouped)
> >      serieses.append((s_name, regrouped))
> 
> You are trying to store a group for later consumption here. 

Good catch, the solution is to turn that loop into a generator,
but then it has to be consumed very carefully.  This stuff
maybe presses the limits of what one can do with Python iterators
while staying sane.  



More information about the Python-list mailing list