Д🥶
py3
Source:
class Dict(dict):
def __or__(self, other):
if isinstance(self, (dict, __class__)) and isinstance(self, (dict, __class__)):
return {**self, **other}
a = Dict(a=1, b=2)
b = Dict(c=3, d=4)
print(a | b)
Result:
{'a': 1, 'b': 2, 'c': 3, 'd': 4}
REXTESTER NOTICE: on April 10 2021 rextester api will no longer serve requests without api key. To get one please visit patreon.com/rextester