Nick Coghlan <ncogh...@gmail.com> added the comment:

*Any* expression can be used as a standalone statement and (since PEP 352 was 
implemented) that now applies to 'yield' as well.

PEP 352 fundamentally changed the way yield was conceptualised within the 
language - thinking of it as "a statement that can be used as an expression" is 
just plain *wrong*. It's now just an expression that happens to have a couple 
of special cases in the grammar to allow the parentheses to be skipped when 
they're distracting rather than helpful.

That is, the only reason the yield statement still exists as a separate entity 
is to allow us to drop the otherwise mandatory parentheses:

  (yield val)    # yield expression as statement
  yield val      # yield statement

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11682>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to