On Tue, Mar 6, 2012 at 12:50 PM, Abhishek Pratap <abhishek....@gmail.com> wrote: > Hi Guys > > I am looking for a way to build dictionaries of dict in python. > > For example in perl I could do > > my $hash_ref = {}; > $hash->{$a}->{$b}->{$c} = "value"; > if (exists $hash->{$a}->{$b}->{$c} ){ print "found value"} > > Can I do something similar with dictionaries in Python. > > > Thanks > -Abhi > > Dictionaries can contain dictionaries in python:
>>> sub_d = {'key1':'value1'} >>> d = {'subd1':sub_d} >>> d {'subd1': {'key1': 'value1'}} >>> d['subd1'] {'key1': 'value1'} >>> The Python site has information here: http://docs.python.org/tutorial/datastructures.html#dictionaries > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Joel Goldstick _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor