Skip to content

Instantly share code, notes, and snippets.

@ShinJJang
Last active August 29, 2015 14:23
Show Gist options
  • Save ShinJJang/a3e393e202b1ee7a9051 to your computer and use it in GitHub Desktop.
Save ShinJJang/a3e393e202b1ee7a9051 to your computer and use it in GitHub Desktop.
To check is same variable with parameter and local variable that have same name
def parameter_local_variable_test(a):
print("init : ", hex(id(a)))
a = 10
print("assign 10 to a : ", hex(id(a)))
a = 5
print("assign different value : ", hex(id(a)))
a = 5
print("same value : " ,hex(id(a)))
# >>> test(10)
# init : 0x6f43c0a0
# assign 10 to a : 0x6f43c0a0 # If argument is same with 10, not changed
# assign different value : 0x6f43c050 # changed
# assign same value : 0x6f43c050 # not changed
# >>> test(2)
# init : 0x6f43c020
# assign 10 to a : 0x6f43c0a0 # if argument is different with 10, changed
# assign different value : 0x6f43c050 # changed
# assign same value : 0x6f43c050 # not changed
@ShinJJang
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment