best practices: is collections.defaultdict my friend or not?

Paul Rubin no.email at nospam.invalid
Fri Mar 5 21:53:46 EST 2010


Pete Emerson <pemerson at gmail.com> writes:
> I found out that adding a two dimensional element without defining
> first dimension existing doesn't work:
>
>>>> data = {}
>>>> data['one']['two'] = 'three'

You can use a tuple as a subscript if you want:

    data = {}
    data['one','two'] = 'three'



More information about the Python-list mailing list