Author tomirendo
Recipients tomirendo
Date 2014-10-29.21:27:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1414618066.52.0.215624025495.issue22761@psf.upfronthosting.co.za>
In-reply-to
Content
Inside a list comprehension expression, if a StopIteration exception is raised, the interpreter assumes the exception was raised by the object Iterated by the list comprehension expression.

For example, this generator will never stop, and will keep returning empty tuples:

def izip(*args):
    iters = [iter(obj) for obj in args]
    while True:
        yield tuple(next(it) for it in iters)
x = izip([1,2],[3,4])
print(next(x)) #(1,3)
print(next(x)) #(2,4)
print(next(x)) #()
History
Date User Action Args
2014-11-01 00:50:36terry.reedyunlinkissue22761 messages
2014-10-29 21:27:46tomirendosetrecipients: + tomirendo
2014-10-29 21:27:46tomirendosetmessageid: <1414618066.52.0.215624025495.issue22761@psf.upfronthosting.co.za>
2014-10-29 21:27:46tomirendolinkissue22761 messages
2014-10-29 21:27:46tomirendocreate