Cannot access sub-keys in OrderedDict
<p>I'm trying to define my ordinary dictionary as an OrderedDict, but I can't seem to access keys are the inner level.</p>

<pre><code>my_dict = \
{
    'key1':
    {
        'subkey1':value1,
        'subkey2':value2
    }
}

my_ordered_dict = OrderedDict\
([(
    'key1',
    (
        ('subkey1',value1),
        ('subkey2',value2)
    )
)])
</code></pre>

<p>I can access <code>['key1']</code> for both cases, but I cannot access <code>['key1']['subkey1']</code> for the ordered dict.</p>

<p>What am I doing wrong?</p>

<p>The dictionary with 'subkey1' should also be defined as a OrderedDict ,if thats what you want.
So it should be something like this</p>

<pre><code>import collections
my_ordered_dict = collections.OrderedDict()
sub_dict=collections.OrderedDict()
sub_dict['subkey1']=1
sub_dict['subkey2']=2
my_ordered_dict['key1']=sub_dict
sub_dict=collections.OrderedDict()
sub_dict['subkey1']=3
sub_dict['subkey2']=4
my_ordered_dict['key2']=sub_dict
print my_ordered_dict['key1']['subkey1']
print my_ordered_dict['key2']['subkey1']
</code></pre>

<p>The out put will be</p>

<pre><code>1
3
</code></pre>

python ordereddictionary