Python complaints

Tim Peters tim_one at email.msn.com
Wed Dec 1 03:15:04 EST 1999


[François Pinard]
> ...
> By the way, I find `map' rather useful, even if I read recently that
> Guido somewhat regretted having introduced it in Python.  I guess one
> could write his/her own `map' function, it is just simpler for the
> community that the order and meaning of arguments is decided once and
> for all in the library.

It's not the functionality of "map" that's objectionable, it's the politics.
Whoever contributed the implementation for map, filter and reduce did an
excellent job on them!  They were perfectly designed (modulo the goofy "None
padding" of "short" arguments), and work great.  The unwanted side-effect is
that their addition opened the doors to endless clamoring for more of the
same, and griping about the limitations of lambda (which was conceived as a
minor convenience, not as the foundation of an alternative programming
style).

Guido doesn't want Python to evolve in Lispish directions, and before those
things were added very few people pushed in those directions.  Ever since,
it's been common.  One of the only times in my life I've seen a "slippery
slope" argument that actually turned out to have merit <0.9 wink>.

There's nothing you can do with "map" you couldn't do "more Pythonically"
with list comprehensions; e.g.

    sq = map(lambda a: a**2, x)

vs

    sq = [a**2 for a in x]

In the bowels of DejaNews you'll find some fully fleshed-out proposals for
adding that, and for generalizing "for" to march over multiple sequences in
lockstep (nice to have in general, and needed to replace multi-argument map
with equal clarity); Greg Ewing has already implemented part of that.

map-by-any-other-name-wouldn't-be-"map"-ly y'rs  - tim






More information about the Python-list mailing list