Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76298 > unrolled thread
| Started by | Makoto Kuwata <kwa@kuwata-lab.com> |
|---|---|
| First post | 2014-08-14 21:57 +0900 |
| Last post | 2014-08-14 21:57 +0900 |
| 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.
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? Makoto Kuwata <kwa@kuwata-lab.com> - 2014-08-14 21:57 +0900
| From | Makoto Kuwata <kwa@kuwata-lab.com> |
|---|---|
| Date | 2014-08-14 21:57 +0900 |
| Subject | Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? |
| Message-ID | <mailman.12993.1408021072.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Aug 14, 2014 at 7:02 PM, Chris Angelico <rosuav@gmail.com> wrote: > 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 > Well, I wrote the above code in order to describe `value is propagated by StopIteration' because I misunderstood that it is propagated by return value of yield statement (see my first post). I have known that `yield from` is very complicated (thanks to your reply). -- regards, kwatch
Back to top | Article view | comp.lang.python
csiph-web