Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76287
| Date | 2014-08-14 18:35 +0900 |
|---|---|
| Subject | [Q] is 'yield from' syntax sugar for 'for'+'yield'? |
| From | Makoto Kuwata <kwatch@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12988.1408008940.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Question about 'yield from'.
I understand that::
yield from xs
is syntax suger of::
for x in xs:
yield x
And::
val = yield from xs
is same as::
for x in xs:
ret = yield x
val = ret
Is it true? Do I understand correctly?
quote from
https://docs.python.org/3/whatsnew/3.3.html#pep-380-syntax-for-delegating-to-a-subgenerator
> For simple iterators, yield from iterable is essentially
> just a shortened form of for item in iterable: yield item:
--
regards,
kwatch
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
[Q] is 'yield from' syntax sugar for 'for'+'yield'? Makoto Kuwata <kwatch@gmail.com> - 2014-08-14 18:35 +0900 Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? Marko Rauhamaa <marko@pacujo.net> - 2014-08-14 12:57 +0300 Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-14 23:43 +1000
csiph-web