permuting over nested dicts?

Christian Meesters meesters at uni-mainz.de
Wed Oct 31 13:21:58 EDT 2007


Hoi,

I have the following data structure (of variable size actually, to make
things simple, just that one):
d = {'a': {'x':[1,2,3], 'y':[4,5,6]},
     'b': {'x':[7,8,9], 'y':[10,11,12]}}
This can be read as a dict of possibilities: The entities 'a' and 'b' have
the parameters 'x' and 'y', each. And d['a']['x'] can be either 1 or 2 or
3. Does anybody know a convenient (and fast) way to permute over all
possible nested dicts like
{'a': {'x':1, 'y':4},
 'b': {'x':7, 'y':10}}
and
{'a': {'x':2, 'y':4},
 'b': {'x':7, 'y':10}}
and so forth?

Any link or snippet is appreciated.

TIA
Christian



More information about the Python-list mailing list