Created
February 15, 2020 19:58
-
-
Save twr14152/1913cc3f76b37223dd4c310e8bcb86af to your computer and use it in GitHub Desktop.
Using deepcopy with dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [64]: dict1 = copy.deepcopy(sample_dict) | |
In [65]: dict1 | |
Out[65]: {'first': 1, 'second': 2, 'third': 3, 'a': 1, 'b': 2} | |
In [66]: sample_dict | |
Out[66]: {'first': 1, 'second': 2, 'third': 3, 'a': 1, 'b': 2} | |
In [68]: sample_dict.pop("first") | |
Out[68]: 1 | |
In [69]: sample_dict | |
Out[69]: {'second': 2, 'third': 3, 'a': 1, 'b': 2} | |
In [70]: dict1 | |
Out[70]: {'first': 1, 'second': 2, 'third': 3, 'a': 1, 'b': 2} | |
In [71]: id(sample_dict) | |
Out[71]: 3024432416 | |
In [72]: id(dict1) | |
Out[72]: 3023654848 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment