Last active
August 29, 2015 14:23
-
-
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
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://wikidocs.net/32