<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small"><span style="font-family:Arial,Helvetica,sans-serif">On Thu, 28 Jul 2022 at 08:57, Marco De Paoli <<a href="mailto:depaolim@gmail.com">depaolim@gmail.com</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span class="gmail_default" style="font-family:arial,sans-serif;font-size:small">=</span></div><div>---><--- begin test_gen.py ---><---</div>def gen():<br> while True:<br> try:<br> yield "A"<br> yield "B"<br> yield "C"<br> except Exception as ex:<br> print("catched exception", ex)<br><br><br>g = gen()<br>you_can_specify_any_number_of_steps = 3<br>for idx in range(you_can_specify_any_number_of_steps):<br> print("result:", g.send(None))<br>print("throw...")<br><span class="gmail_default" style="font-family:arial,sans-serif;font-size:small"></span>g.throw(Exception("BOOM"))<br>print("result:", g.send(None), "*** I was expecting A and I get B, why?!? ***")<br>print("result:", g.send(None))<br><div><br></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small">Se invece di g.throw(Exception("BOOM")) scrivi <span class="gmail_default">print(</span><span style="font-family:Arial,Helvetica,sans-serif">g.throw(Exception("BOOM")))</span></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small"><span style="font-family:Arial,Helvetica,sans-serif"><br></span></div><div class="gmail_default" style="font-size:small">Ritroverai il tuo "A" :-)</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Ciao.<br>Marco.</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
</blockquote></div></div>