2020-02-03 17:25:54 +00:00
|
|
|
def swap(d, key1, key2):
|
|
|
|
if key1 == key2:
|
|
|
|
return
|
2022-07-15 21:54:34 +00:00
|
|
|
val1 = d[key1]
|
|
|
|
val1 = val1.copy() if isinstance(val1, dict) else val1
|
|
|
|
val2 = d[key2]
|
|
|
|
val2 = val2.copy() if isinstance(val2, dict) else val2
|
|
|
|
d[key1], d[key2] = val2, val1
|