py - understanding zip function
Posted t0nsha
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了py - understanding zip function相关的知识,希望对你有一定的参考价值。
understanding zip function
from: http://stackoverflow.com/questions/3865640/understanding-zip-function
12 6 |
All discussion is about python 3.1.2; see Python docs for the source of my question. I know what
Let's say I call The line Inside the loop, I'm sure I'm missing something very simple.. python iterator zip python-3.x
| ||||||||||||||||
|
2 Answers
active oldest votes8 |
It looks like it's a bug in the documentation. The 'equivalent' code works in python2 but not in python3, where it goes into an infinite loop. And the latest version of the documentation has the same problem:http://docs.python.org/release/3.1.2/library/functions.html Looks like change 61361 was the problem, as it merged changes from python 2.6 without verifying that they were correct for python3. It looks like the issue doesn't exist on the trunk documentation set, but you probably should report a bug about it at http://bugs.python.org/.
| ||||||||||||||||||||
|
7 |
It seems like this code is supposed to be read as python-2.x code. It doesn't even run properly in py3k. What happens in python-2.x is that
iterables is a list of 2 iterators, on each iteration within the while loop, next (first remaining) element of iterator is consumed ('
| ||||
|