#http://code.activestate.com/recipes/440502-a-dictionary-with-multiple-values-for-each-key/
class mdict(dict):

    def __setitem__(self, key, value):
        """add the given value to the list of values for this key"""
        self.setdefault(key, []).append(value)

 
if __name__ == '__main__':
    ml = mdict()
    key1 = 'key1'
    ml[key1] = 'val1' 
    ml[key1] = 'val2'
    key2 = 'key2'
    ml[key2] = 'val11' 
    ml[key2] = 'val21'    
    print ml
