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


Groups > comp.lang.python > #76291 > unrolled thread

Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?

Started byChris Angelico <rosuav@gmail.com>
First post2014-08-14 20:02 +1000
Last post2014-08-14 20:02 +1000
Articles 1 — 1 participant

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.


Contents

  Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? Chris Angelico <rosuav@gmail.com> - 2014-08-14 20:02 +1000

#76291 — Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?

FromChris Angelico <rosuav@gmail.com>
Date2014-08-14 20:02 +1000
SubjectRe: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
Message-ID<mailman.12991.1408010569.18130.python-list@python.org>
On Thu, Aug 14, 2014 at 7:59 PM, Makoto Kuwata <kwatch@gmail.com> wrote:
> I understand that 'val = yield from xs' is completely different from::
>
>    for x in xs:
>       ret = yield x
>    val = x
>
> Return value is propagated by StopIteration, like:
>
>    it = iter(xs)
>    try:
>      while 1:
>        yield next(it)
>    except StopIteration as ex:
>      val = ex.value

It's even more complicated than that. The PEP specifies the exact semantics.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web