Skip to content

Instantly share code, notes, and snippets.

@belsander
Created December 11, 2016 15:56
Show Gist options
  • Save belsander/4126eb1a97b314195a97fb6115bda013 to your computer and use it in GitHub Desktop.
Save belsander/4126eb1a97b314195a97fb6115bda013 to your computer and use it in GitHub Desktop.
id(object)
# Example
>>> test_dict1 = {"a": 1, "b": 2}
>>> test_dict2 = test_dict1
>>> test_dict3 = dict(test_dict1) # intiliaze a new dictionary based upon test_dict1
>>> test_dict1
{'a': 1, 'b': 2}
>>> test_dict2
{'a': 1, 'b': 2}
>>> test_dict3
{'a': 1, 'b': 2}
>>> id(test_dict1)
4506794536
>>> id(test_dict2)
4506794536
>>> id(test_dict3)
4506801888
>>> test_dict1 == test_dict2
True
>>> test_dict1 == test_dict3
True
>>> id(test_dict1) == id(test_dict3)
False
>>> id(test_dict1) == id(test_dict2)
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment