Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'propagated': 0.16; 'subject:yield': 0.16; 'xs:': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'subject:] ': 0.20; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'specifies': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'subject:from': 0.34; 'except': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'yield': 0.36; 'pm,': 0.38; 'even': 0.60; 'more': 0.64; 'different': 0.65; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=oNZSJBBgnFi1PYDLyKomat1Z4vszTyhwK384AQffuYk=; b=A/jm6aT4yXPM1oE/CE2Z4yri50YRLUyAfqB7p+CTwIxCoA3S82+UjTj3Aaw8Tuo5qE M/LFGu9zBm9j+sXsB+5BMTwB8GAy1+RYoNU25TGqeTbAkOuDLuUKyRESKqQXXBAexn5d z5bSMExNoj4oN/DgwZ1LQjuIjtIF39n0VQMRJi1WkPbNCdM1rYSB4W0xLZbPk8zNWdr2 nf4Bc3DzTIOHvvq6SAP7C2vxuDnFZ3fQBhwfcyky7f3Oi6elqCcMr7nq/seu/BYq1iCK ij+deF3fykt5TzMIMR5BdujeRiF7ReozZYv9E+y/fkP3y3WWOoaMbVvsnWLSmNK9ZDOL 27Dg== MIME-Version: 1.0 X-Received: by 10.51.17.2 with SMTP id ga2mr15802529igd.2.1408010566254; Thu, 14 Aug 2014 03:02:46 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 Aug 2014 20:02:46 +1000 Subject: Re: [Q] is 'yield from' syntax sugar for 'for'+'yield'? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408010569 news.xs4all.nl 2849 [2001:888:2000:d::a6]:49967 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76291 On Thu, Aug 14, 2014 at 7:59 PM, Makoto Kuwata 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