defining the behavior of zip(it, it) (WAS: Converting a flat list...)

Dave Hansen iddw at hotmail.com
Wed Nov 23 09:44:58 EST 2005


On Tue, 22 Nov 2005 23:17:31 -0700 in comp.lang.python, Steven Bethard
<steven.bethard at gmail.com> wrote:

>rhettinger at gmail.com wrote:
[...]
>> IIRC, this was discussednd rejected in an SF bug report.  It should not
>> be a defined behavior for severals reasons:
>[snip arguments about how confusing zip(it, it) is]
>> Overall, I think anyone using zip(it,it) is living in a state of sin,
>> drawn to the tempations of one-liners and premature optimization.  They
>> are forsaking obvious code in favor of screwy special cases.  The
>> behavior has been left undefined for a reason.
>
>Then why document itertools.izip() as it is?  The documentation there is 
>explicit enough to know that izip(it, it) will work as intended.  Should 
>we make the documentation there less explicit to discourage people from 
>using the izip(it, it) idiom?

ISTM that one would use itertools.izip in order to get some
functionality not available from zip.  Perhaps this is one of those
bits of functionality.

But I admit, I'm not all that familiar with itertools...

In any case, the solution seems obvious: if you want the guarantee,
use the tool that provides it.

Regards,
                                        -=Dave

-- 
Change is inevitable, progress is not.



More information about the Python-list mailing list