<div dir="rtl"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr">I would like to purpose that generator expressions will not catch StopIteration exception, if this exception did not come from the iterated object's __next__ function specifically. So generator expressions will be able to raise StopIteration by calculating the current value of the Generator.</div><div dir="ltr"><br></div><div dir="ltr">Here is an example of a use-case :</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">def izip(*args):</div><div dir="ltr">    iters = [iter(obj) for obj in args]</div><div dir="ltr">    while True:</div><div dir="ltr">        yield tuple(next(it) for it in iters)</div><div dir="ltr"><br></div><div dir="ltr">a = izip([1,2],[3,4])</div><div dir="ltr">print(next(a),next(a),next(a)) #Currently prints : (1, 3) (2, 4) ()</div><div dir="ltr">list(izip([1,2],[3,4])) #Currently never returns</div></div><div dir="ltr"><br></div><div dir="ltr">Even thought this is the PEP described behaviour, I think this is an unwanted behaviour. </div><div dir="ltr"><br></div><div dir="ltr">I think Generator Expressions should work like List Comprehension in that sense:</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">def iizip(*args):</div><div dir="ltr">    iters = [iter(obj) for obj in args]</div><div dir="ltr">    while True:</div><div dir="ltr">        yield tuple([next(it) for it in iters])</div><div dir="ltr"><br></div><div dir="ltr">tuple(iizip([1,2],[3,4])) #Returns [(1, 3), (2, 4)] </div></div></div>