On Sat, Feb 02, 2008 at 11:16:16AM +0900, Stephen J. Turnbull wrote:
> Greg Ewing writes:
> 
>  > Also, if generator expressions had come first, we
>  > would probably never have gotten list comprehensions.
> 
> I don't understand.  A list comprehension is for when you know you're
> going to want to work with the whole list.  Similarly (even more so)
> for dictionary comprehensions.  List comprehension can be defined in
> terms of a genexp, of course, but ISTM it's a worthwhile addition to
> the language in its own right.

I think Greg was just pointing out that with generator expressions, you
can write:

>>> lst = list(x**2 for x in xrange(10))
>>>

which would make it less necessary to the equivalent syntax:

>>> lst = [x**2 for x in xrange(10)]
>>>


-- 
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55  8012 AB4D 6098 8826 6868

Attachment: pgpTm5CNTkikb.pgp
Description: PGP signature

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to