Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'expression,': 0.16; 'iterator,': 0.16; 'keyword.': 0.16; 'parentheses': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'header :User-Agent:1': 0.23; 'expanded': 0.24; 'specify': 0.24; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; '[1]': 0.29; 'dec': 0.30; '-0700,': 0.31; 'subject:learning': 0.31; 'another': 0.32; 'but': 0.35; 'building': 0.35; 'yield': 0.36; 'similar': 0.36; 'example,': 0.37; 'list': 0.37; 'list.': 0.37; 'thank': 0.38; 'to:addr:python- list': 0.38; 'list,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'expression': 0.60; 'ian': 0.60; 'received:130': 0.73; 'missing.': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Seb Subject: Re: learning to use iterators Date: Tue, 23 Dec 2014 13:37:16 -0600 Organization: Church of Emacs References: <878uhyb3hq.fsf@net82.ceos.umanitoba.ca> Mime-Version: 1.0 Content-Type: text/plain X-Gmane-NNTP-Posting-Host: net82.ceos.umanitoba.ca User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:MIJnVeVk67pt/tzBTQLzld3lPNw= 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1419363455 news.xs4all.nl 2906 [2001:888:2000:d::a6]:47916 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82851 On Tue, 23 Dec 2014 12:23:45 -0700, Ian Kelly wrote: > The parentheses enclose a generator expression, which is similar to a > list comprehension [1] but produce a generator, which is a type of > iterator, rather than a list. > In much the same way that a list comprehension can be expanded out to > a for loop building a list, another way to specify a generator is by > defining a function using the yield keyword. For example, this > generator function is equivalent to the generator expression above: [...] Thank you, this exactly what I was missing. Happy holidays, -- Seb