removing list comprehensions in Python 3.0

Steven Bethard steven.bethard at gmail.com
Fri Jul 8 18:07:50 EDT 2005


George Sakkis wrote:
 > "Steven Bethard" <steven.bethard at gmail.com> wrote:
 >> Dict comprehensions were recently rejected:
 >>      http://www.python.org/peps/pep-0274.html
 >> The reason, of course, is that dict comprehensions don't gain you
 >> much at all over the dict() constructor plus a generator expression,
 >> e.g.:
 >>     dict((i, chr(65+i)) for i in range(4))
 >
 > Sure, but the same holds for list comprehensions: list(i*i for i in
 > xrange(10)). The difference is historic I guess; list comprehensions
 > preceded generator expressions and so they cannot be removed, at least
 > not before 3.0. I wonder if they will/should be in the language when
 > the constraint of backwards compatibility is lifted. IMO they should
 > not (TIOOWTDI, uniformity among builtin data structures, not
 > overwhelmingly more useful than set or dict comprehensions), but
 > there's a long way till that day.

I think the jury's still out on this one:

* Alex Martelli expects list comprehensions to be removed. [1]
* Robert Kern wants list comprehensions removed. [2]
* Raymond Hettinger encourages continued use of list comprehensions [3]
* Jeremy Bowers thinks list comprehensions should stay. [4]

I only searched a few relatively recent threads in c.l.py, so there are 
probably more, but it looks to me like the final decision will have to 
be made by a pronouncement from Guido.

[1]http://groups-beta.google.com/group/comp.lang.python/msg/f5613c00cb8c9539
[2]http://groups-beta.google.com/group/comp.lang.python/msg/b2cf0cd72d53fbe5
[3]http://groups-beta.google.com/group/comp.lang.python/msg/781dfab03701dd18
[4]http://groups-beta.google.com/group/comp.lang.python/msg/771a47d9eb24c863



More information about the Python-list mailing list