expression form of one-to-many dict?

Steven Bethard steven.bethard at
Sat Dec 18 00:54:35 CET 2004

Larry Bates wrote:
> Suggestion: It is a bad idea to name any variable
> "map".  When you do, you destroy your ability to call
> Python's map function. Same goes for "list", "str",
> or any other built-in function.
> If you haven't been bitten by this you will, I was.

A good reminder for all the newbies out there.

Sorry, I renamed my variables to simplify the example -- my names 
usually look like '<key>_<value>_map' where <key> and <value> describe 
the items in the dict.  Since the generic example didn't really have a 
description for the keys or values, I stripped it down to map.  Fine for 
the example, but I should have realized it would draw this comment 
(mainly because I probably would have posted a similar one myself if I 
had seen the example). ;)

Fortunately, after 2+ years with Python, the risk of me being "bitten" 
again by this is pretty small. ;)

Actually, it's even smaller now, because I've pretty much removed map 
from all my code in favor of list comprehensions, which I find much 
easier to read.


More information about the Python-list mailing list