[Chicago] 2 unique keys in a python dict?

skip at pobox.com skip at pobox.com
Thu Oct 9 17:49:52 CEST 2008


    Lukasz> Is it possible to have multiple keys in a python dictionary?

Certainly.  Though I don't think that's really what you intended to ask.

    Lukasz> Normally its only 1 key, and I need to have 2 dictionaries and
    Lukasz> somehow manage the uniqueness.
    Lukasz> me={}
    Lukasz> me['First']='Lucas'
    Lukasz> me['Last']='szybalski'

    Lukasz> I would like to get 2 keys? Is there something similar to dict
    Lukasz> that would have the property that 2 or more keys are unique?
    Lukasz> me= ?

I'm unclear what you are asking.  Do you want a list of dictionaries?, e.g.:

    names = [
        {
            'First': 'Lucas',
            'Last': 'Szybalski',
        },
        {
            'First': 'Skip',
            'Last': 'Montanaro',
        }
    ]

Skip


More information about the Chicago mailing list