pairs from a list
Alan Isaac
aisaac at american.edu
Tue Jan 22 11:10:53 EST 2008
Arnaud Delobelle wrote:
> According to the docs [1], izip is defined to be equivalent to:
>
> def izip(*iterables):
> iterables = map(iter, iterables)
> while iterables:
> result = [it.next() for it in iterables]
> yield tuple(result)
>
> This guarantees that it.next() will be performed from left to right,
> so there is no risk that e.g. pairs4([1, 2, 3, 4]) returns [(2, 1),
> (4, 3)].
>
> Is there anything else that I am overlooking?
>
> [1] http://docs.python.org/lib/itertools-functions.html
<URL:http://bugs.python.org/issue1121416>
fwiw,
Alan Isaac
More information about the Python-list
mailing list