magical expanding hash

Paul Rubin http
Tue Jan 17 17:12:16 CET 2006

"Diez B. Roggisch" <deets at> writes:
> > BTW: remember that setdefault() is written "setdefault()" but it's read
> > "getorset()".
> I can only second that. The misleading name has - well, mislead me :)


   x[a][b][c][d] = e    # x is a "magic" dict


   x.setdefault(a,{}).setdefault(b,{}).setdefault(c,{})[d] = e

if I understand correctly.  Ugh.

More information about the Python-list mailing list