I have a set() with terms like ‘A’ ‘B’ ‘C’. I want a 2-d associative array so that i can perform an operation like d['A']['B'] += 1 . What is the pythonic way of doing this, I was thinking a dicts of dicts. Is there a better way.
I have a set() with terms like ‘A’ ‘B’ ‘C’. I want a 2-d
Share
Is there any reason not to use a dict of dicts? It does what you want (though note that there’s no such thing as
++in Python), after all.There’s nothing stylistically poor or non-Pythonic about using a dict of dicts.