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


Groups > comp.lang.python > #82851

Re: learning to use iterators

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 <python-python-list@m.gmane.org>
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 <spluque@gmail.com>
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> <CALwzid=CjpFPHUhPEbUy537+GCD_jnnZMZdzUx5x9y5=uVsO9A@mail.gmail.com>
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 <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.17162.1419363455.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, 23 Dec 2014 12:23:45 -0700,
Ian Kelly <ian.g.kelly@gmail.com> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: learning to use iterators Seb <spluque@gmail.com> - 2014-12-23 13:37 -0600

csiph-web