magical expanding hash

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


"Diez B. Roggisch" <deets at nospam.web.de> 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 :)

Hmm,

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

becomes

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

if I understand correctly.  Ugh.



More information about the Python-list mailing list