map/filter/reduce/lambda opinions and background unscientific mini-survey

George Sakkis gsakkis at
Fri Jul 8 21:51:14 CEST 2005

"Steven Bethard" <steven.bethard at> wrote:

> Christopher Subich wrote:
> > Ron Adam wrote:
> >> I think the association of (lambda) to [list_comp] is a nice
> >> distinction.  Maybe a {dictionary_comp} would make it a complete set. ;-)
> >
> > Yeah, dictionary comprehensions would be an interesting feature. :)
> > Syntax might be a bit unwieldy, though, and I doubt they'd be used often
> > enough to be worth implementing, but still neat.
> Dict comprehensions were recently rejected:
> 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.


More information about the Python-list mailing list