Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107423 > unrolled thread
| Started by | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| First post | 2016-04-20 13:01 -0700 |
| Last post | 2016-04-21 09:23 +1000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2016-04-20 13:01 -0700 |
| Subject | Re: PEP proposal: sequence expansion support for yield statement: yield * |
| Message-ID | <mailman.38.1461182430.12923.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | kenseehart@gmail.com |
|---|---|
| Date | 2016-04-20 15:26 -0700 |
| Message-ID | <a01d99fa-b794-4a69-a29c-c902256d50db@googlegroups.com> |
| In reply to | #107423 |
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
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-04-21 09:23 +1000 |
| Message-ID | <mailman.41.1461194646.12923.python-list@python.org> |
| In reply to | #107426 |
On Thu, Apr 21, 2016 at 8:26 AM, <kenseehart@gmail.com> wrote: > 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. > This is what happens when you make proposals. Guido van Rossum has a time machine, and he'll go back in time, implement the feature, and quietly come back here :) Keep on thinking about what would make the language better. Ideas are great! But do remember to check the latest version of Python (currently 3.5, with 3.6 in development); no new features will be added to 2.7. In fact, I'd recommend making the switch to 3.5 as soon as possible; you'll gain quite a few cool new features. All the best! ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web