Wednesday, November 2, 2011

Python: "Extend" like method for a Dict


a = { "a" : 1, "b" : 2 }
b = { "c" : 3, "d" : 4 }
a.update(b)
print a # prints { "a" : 1, "b" : 2, "c" : 3, "d" : 4 }


Source:
http://stackoverflow.com/questions/577234/python-extend-for-a-dictionary
Reference:
http://docs.python.org/library/stdtypes.html#mapping-types-dict

No comments: