zip broken?

Gerhard Häring gh at ghaering.de
Sat Jun 7 19:18:55 EDT 2003


Erik Max Francis wrote:
> Marek "Baczek" Baczyñski wrote:
>>I found a behaviour of zip() which I don't like -- it hangs on
>>infinite generators. Consider this code:
> 
> zip only works on finite sequences -- if you think about it, it has to;
> it's a standalone function (i.e., not a generator itself), so it has to
> finish what it's doing before it returns anything.  And since it needs
> to read in the whole sequence to rearrange it, it must only work on
> finite sequences.

The first (and only ;-) things I played around with generators was 
iterzip, itermap and iterator versions of combinations. Who else hasn't? ;-)

-- Gerhard





More information about the Python-list mailing list