zip broken?

Alexander Schmolck a.schmolck at gmx.net
Sun Jun 8 08:19:14 EDT 2003


Erik Max Francis <max at alcyone.com> writes:

> 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;

Not true, only one of the sequences has to be finite.

>>> def yes():
...     while 1: yield 'yes'
...
>>> zip(yes(), range(3))
[('yes', 0), ('yes', 1), ('yes', 2)]


'as




More information about the Python-list mailing list