Python dictionary: set value as the key string
Question: I have a python dictionary and want to set one of the values as the key itself
whilst initializing the dict. That is:

    
    
    dummy = dict(
      Key1 = ["SomeValue1", "Key1"],
      Key2 = ["SomeValue2", "Key2"],
      )
    

Can this be done programmably? That is, to skip writing the key again and set
something like `dummy.keys()[currentkeyindex]`.


Answer: If you want to keep track of items as well then use
[defaultdict](https://docs.python.org/2/library/collections.html#collections.defaultdict)

    
    
    >>> from collections import defaultdict                                                                                                      
    >>> output = defaultdict(list)
    >>> values = [
            ["SomeValue1", "Key1"],
            ["SomeValue2a", "Key2"],
            ["SomeValue2b", "Key2"]
        ]
    >>> for x in values:
    ...     output[x[1]].append(x)
    ... 
    >>> output
    defaultdict(<type 'list'>, {
        'Key2': [['SomeValue2a', 'Key2'], ['SomeValue2b', 'Key2']], 
        'Key1': [['SomeValue1', 'Key1']]
    })
    

