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


Groups > comp.lang.python > #82851

Re: learning to use iterators

From Seb <spluque@gmail.com>
Subject Re: learning to use iterators
Date 2014-12-23 13:37 -0600
Organization Church of Emacs
References <878uhyb3hq.fsf@net82.ceos.umanitoba.ca> <CALwzid=CjpFPHUhPEbUy537+GCD_jnnZMZdzUx5x9y5=uVsO9A@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.17162.1419363455.18130.python-list@python.org> (permalink)

Show all headers | 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