How to efficently build a nested dictionary

Carsten Gaebler cg at schlund.de
Sat Mar 10 13:26:57 EST 2001


Aahz Maruch wrote:
> >
> >traffic = {dir: {year: {month: {day: 42}}}}
> 
> I think Emile's suggestion to use a single compound key is a good one.
> If that's not sufficient *and* you can use Python 2.0, take a look at
> the dict.setdefault() method.

How could the setdefault() method help me out?

cg.



More information about the Python-list mailing list