<p dir="ltr">Ah, that's a good point (the two-directionality of yield had slipped my mind). I had considered suggesting return instead of yield, which wouldn't have that problem, but it felt like return would be more confusing to see in a context where it doesn't actually return from the enclosing scope.</p>
<div class="gmail_quote">On Feb 12, 2014 7:16 PM, "Chris Angelico" <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Feb 13, 2014 at 2:08 PM, Amber Yust <<a href="mailto:amber.yust@gmail.com">amber.yust@gmail.com</a>> wrote:<br>
> Why not use yield instead of else?<br>
><br>
> foo = something() except BazException yield "bar"<br>
<br>
yield is already an expression. It'd be theoretically and<br>
syntactically valid (if a little weird) to use yield "bar" in place of<br>
the name BazException; you'd yield "bar" to your caller, then whatever<br>
exception gets sent in would be the one tested for. I honestly cannot<br>
conceive of any situation where this would actually be useful, but it<br>
does make it a little tricky to reuse that keyword :)<br>
<br>
ChrisA<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>