This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rami
Recipients docs@python, rami
Date 2017-08-24.16:30:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503592223.48.0.262016465806.issue31270@psf.upfronthosting.co.za>
In-reply-to
Content
I just noticed that in my post I accidentally pasted MY implementation twice instead of the old one, sorry for that. Here's the old one for quick comparison:

class ZipExhausted(Exception):
    pass

def zip_longest(*args, **kwds):
    # zip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D-
    fillvalue = kwds.get('fillvalue')
    counter = len(args) - 1
    def sentinel():
        nonlocal counter
        if not counter:
            raise ZipExhausted
        counter -= 1
        yield fillvalue
    fillers = repeat(fillvalue)
    iterators = [chain(it, sentinel(), fillers) for it in args]
    try:
        while iterators:
            yield tuple(map(next, iterators))
    except ZipExhausted:
        pass
History
Date User Action Args
2017-08-24 16:30:23ramisetrecipients: + rami, docs@python
2017-08-24 16:30:23ramisetmessageid: <1503592223.48.0.262016465806.issue31270@psf.upfronthosting.co.za>
2017-08-24 16:30:23ramilinkissue31270 messages
2017-08-24 16:30:23ramicreate