Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107426

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

Newsgroups comp.lang.python
Date 2016-04-20 15:26 -0700
References <573e61523bfc412ca8674b06d70f2fd7@sraex01sc.sisa.samsung.com> <5717E01F.3020804@stoneleaf.us> <mailman.38.1461182430.12923.python-list@python.org>
Message-ID <a01d99fa-b794-4a69-a29c-c902256d50db@googlegroups.com> (permalink)
Subject Re: PEP proposal: sequence expansion support for yield statement: yield *
From kenseehart@gmail.com

Show all headers | View raw


On Wednesday, April 20, 2016 at 1:00:45 PM UTC-7, Ethan Furman wrote:
> On 04/20/2016 12:34 PM, Ken Seehart wrote:
> 
> New ideas for Python are typically vetted on Python Ideas. [1]
> 
> > Currently the common pattern for yielding the elements in a sequence
>  > is as follows:
> >
> >    for x in sequence: yield x
> >
> > I propose the following replacement (the result would be identical):
> >
> >    yield *sequence
> >
> > The semantics are somewhat different from argument expansion (from
>  > which the syntax is borrowed), but intuitive: yield all of the elements
>  > of a sequence (as opposed to yield the sequence as a single item).
> 
> Your examples do not make clear what your result should be.  If you mean 
> the results are exactly the same you can get that behavior with
> 
>      yield from iter(x)
> 
> which, while being slightly longer, has the advantage of already 
> working.  ;)
> 
> --
> ~Ethan~
> 
> [1] https://mail.python.org/mailman/listinfo/python-ideas

To be clear, the comment "...(the result would be identical)" is indicative that the result would be identical, meaning "exactly the same".

Anyway, thanks for the link. And I suppose checking Python 3 for implementation would be a good prior step as well! Sadly, "yield from" is not in python 2.7, but it's presence in python 3.3 renders my proposal dead as a parrot without a liver.

Regards,
Ken

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: PEP proposal: sequence expansion support for yield statement: yield * Ethan Furman <ethan@stoneleaf.us> - 2016-04-20 13:01 -0700
  Re: PEP proposal: sequence expansion support for yield statement: yield * kenseehart@gmail.com - 2016-04-20 15:26 -0700
    Re: PEP proposal: sequence expansion support for yield statement: yield * Chris Angelico <rosuav@gmail.com> - 2016-04-21 09:23 +1000

csiph-web