On Tue, Sep 22, 2009 at 5:50 PM, Support Desk <support.desk....@gmail.com> wrote: > I need help searching a large python dictionary. The dictionary is setup > like so > > Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}] > > Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}] > > Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}] >
These look like you're indexing objects Key, Key2, Key3 by dictionaries, or possibly these are the result of printing dict-like objects with custom __repr__() methods. Could you give more information about what's actually going on here? > What would be the best way to search for a specific value of item1 and add > all the results to a new dictionary? Thanks "Searching" a dict is accomplished by simply asking for the key: d['item1'] I'm going to guess you meant something like this: list_of_dicts = [Key, Key2, Key3] new_dict = {} for i, k in enumerate(list_of_dicts): value = k['item1'] if value == some_specific_value: new_dict[i] = value But it's not really clear from your post exactly what you meant to ask. > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list