I am intrigued by the following python expression:
d3 = dict(d1, **d2)
The task is to combine 2 dictionaries into a third, and the above expression does an excellent job. I'm interested in the ** operator and what exactly does it do with the expression. I thought ** was a power operator and had not yet seen him in the context above.
Full code snippet:
>>> d1 = {'a': 1, 'b': 2} >>> d2 = {'c': 3, 'd': 4} >>> d3 = dict(d1, **d2) >>> print d3 {'a': 1, 'c': 3, 'b': 2, 'd': 4}
operators python dictionary syntax set-operations
λ Jonas Gorauskas Feb 12 '10 at 23:57 2010-02-12 23:57
source share