Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: Python Iterables struggling using map() built-in Date: Mon, 08 Dec 2014 18:06:44 +1300 Lines: 16 Message-ID: References: <004e01d01173$e1641c10$a42c5430$@gmail.com> <5484e3d8$0$13013$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ltCRxNYNBglO1MS2moDtoAfZlbkN/Df9xJ1MeJBJnVtlxKohV+ Cancel-Lock: sha1:kmL0ZQtJlqaKckvnlEOY82deQo8= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:82106 Terry Reedy wrote: > However, this 'beautiful' code has a trap. If one gets rid of the > seemingly unneeded temporary list res by telescoping the last two lines > into a bit too much into > > yield tuple(next(i) for i in iters) > > we now have an infinite generator, because tuple() swallows the > StopIteration raised as a side-effect of next calls. An excellent example of the kind of thing that PEP 479 is designed to catch! There couldn't be a better advertisement for it. :-) -- Greg