efficient updating of nested dictionaries
Duncan Booth
me at privacy.net
Mon Jan 26 04:39:09 EST 2004
Josiah Carlson <jcarlson at nospam.uci.edu> wrote in
news:bv2e21$j5e$2 at news.service.uci.edu:
>> Although, that's probably kind of lame - I bet others will have much
>> better suggestions. I'm interested in how other people do this too.
>> Rich
>
> String concatenation is not that lame, but I'd use tuples:
> MY_DICT[(KEY_X, KEY_Y, KEY_Z)] = FOO
>
> Tuples save on string operations.
I would omit the extra parentheses here, but its a style thing.
MY_DICT[KEY_X, KEY_Y, KEY_Z] = FOO
(Note to original poster: I'd also turn off caps-lock)
More information about the Python-list
mailing list