updating dictionaries from/to dictionaries
Brandon
your.master at gmail.com
Thu Aug 14 20:35:29 EDT 2008
> (1) iterating over foo:
> for key in foo:
> foo[key] += bar.get(key, 0)
>
> (2) iterating over bar:
> for key in bar:
> foo[key] += bar[key]
>
> I (again) challenge you to say *why* you feel that the "iterating over
> bar" solution will not work.
Well if you're going to be clever enough to iterate over bar and then
send the results to another dictionary altogether, I obviously cannot
put up a good argument on this matter!
Thanks for the input, I appreciate it.
More information about the Python-list
mailing list