Jan-11-2019, 04:26 PM
>>> x = {"a": 1} >>> b = dict(x) >>> b {'a': 1} >>> #or using keyword expansion: >>> c = dict(**x) >>> c {'a': 1} >>> #make sure they aren't just shallow copies >>> x["b"] = 2 >>> x {'a': 1, 'b': 2} >>> b {'a': 1} >>> c {'a': 1}