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


Groups > comp.lang.python > #76298

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <kwatch@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; "subject:' ": 0.07; 'ex:': 0.09; 'pep': 0.09; 'try:': 0.09; 'val': 0.09; 'cc:addr:python-list': 0.11; 'wrote': 0.14; 'propagated': 0.16; 'subject:yield': 0.16; 'xs:': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'thu,': 0.19; 'subject:] ': 0.20; 'aug': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'specifies': 0.24; 'cc:2**0': 0.24; '&gt;': 0.26; '(see': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; 'subject:from': 0.34; 'except': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'yield': 0.36; 'skip:- 10': 0.38; 'pm,': 0.38; 'even': 0.60; 'first': 0.61; 'more': 0.64; 'different': 0.65; 'to:addr:gmail.com': 0.65
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=a5EDJptoQvS2L2l93Y9R7QOGeHGBXcBLtkqqfObBXBw=; b=T9PBCLBQ/meMKPTk80Q0YRnsD485tDQrmi1C+nwLkOj3MXDj2ja8q/7xGIBtRxLTAm E3NXIh8emvpCsm3VCMYiaaN39ae+DIZfAoCzDR+Hf7jsNvAnf3MD3kMizYnUFhd1IIP5 fSxwUOjl9P0SWS6jyahN0yIc8kuU/5HIrCpvNT/CzlJ6kHJ97ypYn1hv5scz74CVeIky mtJudQnD0qQUZ2Ej0Ru5+wdl9zUNKp/UpzZio+/VwX82ayh/v0ANOG1PDgSaVw1ZRfoB 3TApK2LP9xXz7/bylQW8tB9KciIp5aa1cd2HA8OJsZ2KH1mnzzlNTx3eBF4OlWEGehZH wS3A==
MIME-Version 1.0
X-Received by 10.42.84.9 with SMTP id j9mr14651645icl.60.1408021063317; Thu, 14 Aug 2014 05:57:43 -0700 (PDT)
Sender kwatch@gmail.com
In-Reply-To <CAPTjJmrOVaMFYgHHzXn-ppSZRBSehisc4qLmrrjcuMWcXtM4VA@mail.gmail.com>
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 Thu, 14 Aug 2014 21:57:43 +0900
X-Google-Sender-Auth FhXDCVQA9rqy9WQO9SAnjsApgiM
Subject Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'?
From Makoto Kuwata <kwa@kuwata-lab.com>
To Chris Angelico <rosuav@gmail.com>
Content-Type multipart/alternative; boundary=90e6ba614d4850c235050096732b
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12993.1408021072.18130.python-list@python.org> (permalink)
Lines 82
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408021072 news.xs4all.nl 2942 [2001:888:2000:d::a6]:36862
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76298

Show key headers only | View raw


[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


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