New submission from yotamv: 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)) #() ---------- components: Interpreter Core messages: 230246 nosy: tomirendo priority: normal severity: normal status: open title: Catching StopIteraion inside list comprehension type: behavior versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22761> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com