[docs] [issue10029] "Equivalent to" code for zip is wrong in Python 3

Alexander Belopolsky report at bugs.python.org
Tue Oct 5 20:57:39 CEST 2010

Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Note that the following variant where maps are replaced with list comprehensions seems to work:

def zip(*iterables):
    # zip('ABCD', 'xy') --> Ax By                                                                                                                                                      
    iterables = [iter(i) for i in iterables]
    while iterables:
	yield tuple([next(j) for j in iterables])


Python tracker <report at bugs.python.org>

More information about the docs mailing list