dictionary of dictionaries

kettle Josef.Robert.Novak at gmail.com
Sun Dec 9 03:35:18 EST 2007


Hi,
 I'm wondering what the best practice is for creating an extensible
dictionary-of-dictionaries in python?

 In perl I would just do something like:

my %hash_of_hashes;
for(my $i=0;$i<10;$i++){
    for(my $j=0;$j<10;$j++){
	${$hash_of_hashes{$i}}{$j} = int(rand(10));
    }
}

but it seems to be more hassle to replicate this in python.  I've
found a couple of references around the web but they seem cumbersome.
I'd like something compact.
-joe



More information about the Python-list mailing list