Hash map with multiple keys per value ?

Robert Kern robert.kern at gmail.com
Fri Nov 11 22:57:27 EST 2005


Chris Stiles wrote:
> Hi --
> 
> I'm working on something that includes the concept of multiple aliases for a
> particular object, where a lookup for any of the aliases has to return all the
> others.  The hack way of doing this was to have a dictionary where each 
> entry consisted of a list of all the aliases - with multiple references to the
> same list from the various dictionary entries corresponding to each alias.
> 
> Is there an easier and cleaner way of doing this ?  Is there example code
> floating around that I might have a look at ?

It's what everybody else does. You may want to use sets instead of
lists, but otherwise I think your approach is pretty standard.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list