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


Groups > comp.lang.python > #80992

Re: Different behaviour in list comps and generator expressions

Date 2014-11-17 18:20 -0800
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: Different behaviour in list comps and generator expressions
References <545d76fe$0$12980$c3e8da3$5496439d@news.astraweb.com> <546a8524$0$12990$c3e8da3$5496439d@news.astraweb.com> <CAGGBd_o6t0y2KnTjp-x9O6fpj_RV2JqG09kxGoPkC5tWwbxutA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15966.1416277211.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 11/17/2014 03:38 PM, Dan Stromberg wrote:
> 
> I'm inclined to say that list comprehensions and generator expressions
> should be different.  I don't really think they should be identical,
> one being eager and one being lazy.  Why let the implementation detail
> of one impact the other?

It's not the eagerness vs. laziness that's being changed, but rather what happens in a generator when something inside
the generator raises StopIteration (as opposed to the generator itself simply return'ing and thereby causing a
StopIteration to be generated).

--
~Ethan~

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


Thread

Different behaviour in list comps and generator expressions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-08 12:50 +1100
  Re: Different behaviour in list comps and generator expressions Roy Smith <roy@panix.com> - 2014-11-07 23:39 -0500
  Re: Different behaviour in list comps and generator expressions Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-11-08 22:31 +0100
  Re: Different behaviour in list comps and generator expressions Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-11-08 23:42 +0100
  Re: Different behaviour in list comps and generator expressions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-18 10:30 +1100
    Re: Different behaviour in list comps and generator expressions Dan Stromberg <drsalists@gmail.com> - 2014-11-17 15:38 -0800
    Re: Different behaviour in list comps and generator expressions Ethan Furman <ethan@stoneleaf.us> - 2014-11-17 18:20 -0800

csiph-web