Skip to content

Instantly share code, notes, and snippets.

@jan25
Last active September 17, 2019 12:10
Show Gist options
  • Save jan25/834d7ac7f25120fd2b3c755139908cfb to your computer and use it in GitHub Desktop.
Save jan25/834d7ac7f25120fd2b3c755139908cfb to your computer and use it in GitHub Desktop.
def foo(dict, n=2):
if n == 0: return
dict1 = dict
dict[n] = n
foo(dict, n - 1)
dict2 = dict
# At this point dict1 and dict2 point to same object
# if n == 2 then
# dict, dict1, dict2 point to this
# {
# 2: 2,
# 1: 1
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment