If I have two dictionaries I'd like to combine in Python, i.e.
a = {'1': 1, '2': 2}
b = {'3': 3, '4': 4}
If I run update on them it reorders the list:
a.update(b)
{'1': 1, '3': 3, '2': 2, '4': 4}
when what I really want is attach "b" to the end of "a":
{'1': 1, '2': 2, '3': 3, '4': 4}
Is there an easy way to attach "b" to the end of "a" without having to manually combine them like so:
for key in b:
a[key]=b[key]
Something like += or append() would be ideal, but of course neither works on dictionaries.