Unrelated to python 3.7, but they recently added this feature that you can add two dictionaries together in 3.5 by doing:
new_dict = {**dict1, **dict2}
It is so handy and nice new_dict = {**dict1, **dict2}
It is so handy and nice >>> d = {**{1:2,2:2,3:2}
,**{4:2,5:2,6:2}
,**{7:2,8:2,9:2}}
>>> d
{ 1: 2, 2: 2, 3: 2
, 4: 2, 5: 2, 6: 2
, 7: 2, 8: 2, 9: 2}https://www.python.org/dev/peps/pep-0448/
EDIT: yeah, nvm, it's what everyone else said.
>>> a = {'x': 1}
>>> b = {'x': 2}
>>> {**a, **b}
{'x': 2}
>>> {**b, **a}
{'x': 1} >>> dict1 = {"key1": 1, "key2": "hello", "key3": [1, 2, 3]}
>>> dict2 = {key1": 1, "key2": "world", "key3": [1, 4], "key4": "4"}
>>> {**dict1, **dict2}
{'key1': 1, 'key2': 'world', 'key3': [1, 4], 'key4': '4'} >>> {**{'a': 'first'}, **{'a': 'second'}}
{'a': 'second'}Seems similar to the spread operator in JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Given
a = {1: 1}
b = {2: 2}
This c = {**a, **b}
is equivalent to c = {1: 1, 2: 2} {1,2}|{2,3} == {1,2,3}
I guess the reason they went for the weird {∗∗a, ∗∗b} syntax is that it is not a commutative operation. >>> s1 = {'a', 'b', 'c'}
>>> s2 = {1, 2, 3}
>>> {*s1, *s2}
{'b', 1, 2, 3, 'c', 'a'}
>>> l1 = ['a', 'b', 'c']
>>> l2 = [1, 2, 3]
>>> [*l1, *l2]
['a', 'b', 'c', 1, 2, 3]In PyCharm if you return from within a contextlib.suppress context it'll think any code following it is unreachable code.
https://youtrack.jetbrains.com/issue/PY-25809 https://youtrack.jetbrains.com/issue/PY-16419
dict(dict1, **dict2)Source: https://stackoverflow.com/questions/38987/how-to-merge-two-d...