[issue11682] PEP 380 reference implementation for 3.3

Nick Coghlan report at bugs.python.org
Wed Nov 23 01:55:39 CET 2011


Nick Coghlan <ncoghlan at 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 <report at bugs.python.org>
<http://bugs.python.org/issue11682>
_______________________________________


More information about the Python-bugs-list mailing list