Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'essentially': 0.04; 'syntax': 0.04; "subject:' ": 0.07; 'val': 0.09; 'item:': 0.16; 'iterable': 0.16; 'iterable:': 0.16; 'iterators,': 0.16; 'subject:yield': 0.16; 'url:whatsnew': 0.16; 'xs:': 0.16; 'subject:] ': 0.20; 'to:name:python-list@python.org': 0.22; 'question': 0.24; '>': 0.26; 'message-id:@mail.gmail.com': 0.30; 'url:python': 0.33; 'subject:from': 0.34; 'received:google.com': 0.35; 'yield': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'subject:[': 0.39; 'quote': 0.39; 'to:addr:python.org': 0.39; 'url:3': 0.61; 'simple': 0.61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=HFiRNa+xXTpFa94o3SbWKWMrLy3VwyfMAhBFgQL4bJ8=; b=voWWzivKcATov6XdPhE6WbZPhSFaB6jL5CJSJpVZf4bfnx3ZfcZ9PlJDQBl5egbP/0 ahxvf4Xn/3e3XBVIxSX4QhX+f6To+nrsMJ6VFNamTlynWAU8sJrWiFo13KJ1+llWYUGD LbDKiMK/YNPDjW6OacZvsUdVTNhzSonb9g3Qz38kba/CG4KDbtfsYDrWWoD8W0ukJc/f gykv9jkE70Ek7iXOZaQwtE/V3OVkv2u+SBIkezl73LKTJ/VPV43jeaPGwU6AGHobyTux 245eYmjCMKbh0BNR5BTFjagxEV1uRzrH6FKW8Wfey+3+pW5cqDQnOzRfm1GMYLPqGd6P axAg== MIME-Version: 1.0 X-Received: by 10.43.167.196 with SMTP id nf4mr13038363icc.22.1408008936946; Thu, 14 Aug 2014 02:35:36 -0700 (PDT) Date: Thu, 14 Aug 2014 18:35:36 +0900 Subject: [Q] is 'yield from' syntax sugar for 'for'+'yield'? From: Makoto Kuwata To: "python-list@python.org" Content-Type: multipart/alternative; boundary=001a11c2d676870478050093a024 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: 59 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408008940 news.xs4all.nl 2838 [2001:888:2000:d::a6]:37899 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76287 --001a11c2d676870478050093a024 Content-Type: text/plain; charset=UTF-8 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 --001a11c2d676870478050093a024 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Question about 'yield from'.

I understand that::

=C2=A0 =C2=A0 yield f= rom xs

is syntax suger of::

=C2=A0 =C2=A0 for x in xs:
=C2=A0 =C2=A0 =C2=A0 yield x

And::
=
=C2=A0 =C2=A0 val =3D yield from xs

is same as::

=C2=A0 =C2=A0 for x in xs:
=C2=A0 =C2=A0 =C2=A0 ret =3D yield x
=C2=A0 =C2=A0 val =3D ret

Is it true? Do I understand correctly?


> For simple iterators, yield from iterable is essentially
> just a shortened form of for item in iterable: yield item:

--
regards,
kwatch
--001a11c2d676870478050093a024--