Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76298
| References | <CAFTm5Ru8nfNt2UtyeBiEh-7Cf5RQZShYV9ha=6HACifCcVUG4w@mail.gmail.com> <CAPTjJmo-0aqxeosa1bM=jtuAdwoZLiiG20kDp7RGvP3Zx65_9w@mail.gmail.com> <CAFTm5RuPvUaMarWLeATmi7RG5n+rhcw+JE_11fx3dPMp=bN8bA@mail.gmail.com> <CAPTjJmrOVaMFYgHHzXn-ppSZRBSehisc4qLmrrjcuMWcXtM4VA@mail.gmail.com> |
|---|---|
| Date | 2014-08-14 21:57 +0900 |
| Subject | Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? |
| From | Makoto Kuwata <kwa@kuwata-lab.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12993.1408021072.18130.python-list@python.org> (permalink) |
[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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? Makoto Kuwata <kwa@kuwata-lab.com> - 2014-08-14 21:57 +0900
csiph-web