Add two dicts

Afanasiy abelikov72 at
Fri Aug 29 06:11:09 CEST 2003

I have some code like this...

    lots of stuff here with %(these)s named expressions
    % vars(self)

Then I wanted to add an item to the dict vars(self), so I tried :


This doesn't work, perhaps because no one could decide what should happen
to keys which already exist in the dict? (I'd say throw an exception).

Can I add two dicts in a way which is not cumbersome to the above % string
operation? Is this another case of writing my own function, or does a
builtin (or similar) already exist for this?

More information about the Python-list mailing list