This commit is contained in:
Raymond Hettinger 2011-10-30 15:07:01 -07:00
commit 5d12faa5b8
2 changed files with 19 additions and 10 deletions

View file

@ -1375,10 +1375,10 @@ are always available. They are listed here in alphabetical order.
def zip(*iterables):
# zip('ABCD', 'xy') --> Ax By
sentinel = object()
iterables = [iter(it) for it in iterables]
while iterables:
iterators = [iter(it) for it in iterables]
while iterators:
result = []
for it in iterables:
for it in iterators:
elem = next(it, sentinel)
if elem is sentinel:
return