Author tomirendo
Recipients tomirendo
Date 2014-10-29.21:19:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1414617541.45.0.218818215506.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 buy 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-10-29 21:19:01tomirendosetrecipients: + tomirendo
2014-10-29 21:19:01tomirendosetmessageid: <1414617541.45.0.218818215506.issue22761@psf.upfronthosting.co.za>
2014-10-29 21:19:01tomirendolinkissue22761 messages
2014-10-29 21:19:01tomirendocreate