How to efficently build a nested dictionary

Carsten Gaebler cg at schlund.de
Sat Mar 10 13:38:00 EST 2001


Carel Fellinger wrote:
> 
> or use newer Python goodies like:
> 
>    m = traffic.setdefault(dir,{}).setdefault(year,{}).setdefault(month,{})
>    m[day] = m[day] + bytes
> 

That's it. Thanks!

cg.



More information about the Python-list mailing list