PEP proposal: sequence expansion support for yield statement: yield *

Chris Angelico rosuav at gmail.com
Thu Apr 21 11:26:46 EDT 2016


On Fri, Apr 22, 2016 at 1:19 AM, justin walters
<walters.justin01 at gmail.com> wrote:
> I agree with the others that the new syntax is not needed.
>
> I would also like to point out that I believe any new added syntax or
> functionality should avoid the use of '*' and '**' as both of these
> characters are already used for many things such as optional arguments and
> mathematical operators. Adding more uses for said characters only decreases
> the readability of the code.

The single asterisk is used for packing and unpacking, though. See PEP
448 [1] for some of the ways this can be used (in the context of "the
ways this can NOW be used in Python 3.5"). So the proposed "yield
*sequence" does make good sense; however, "yield from" has, as Steven
pointed out, *far* more detailed semantics, as it basically allows
generators to be refactored, with all their semantics (yield, send,
throw, return).

ChrisA

[1] https://www.python.org/dev/peps/pep-0448/



More information about the Python-list mailing list