I have a project of converting one database to another. One of the original database columns defines the row\'s category. This column should be mapped to a new category in t
You could override dict's indexer, but perhaps the following simpler solution would be better:
>>> assoc_list = ( (('parrot','spam','cheese_shop'), 'sketch'), (('Cleese', 'Gilliam', 'Palin'), 'actors') )
>>> equiv_dict = dict()
>>> for keys, value in assoc_list:
for key in keys:
equiv_dict[key] = value
>>> equiv_dict['parrot']
'sketch'
>>> equiv_dict['spam']
'sketch'
(Perhaps the nested for loop can be compressed an impressive one-liner, but this works and is readable.)