+ 2

how I can find in python place of variable in memory?

e.g. in c++ it is &var

28th Feb 2018, 3:47 PM
Michael
Michael - avatar
5 Answers
+ 2
Did you meant in hexadecimal format? Here you go: print(hex(id(x)))
1st Mar 2018, 11:06 AM
777
777 - avatar
+ 2
@Michael After a lot of research on this, I ended up with a new code: https://code.sololearn.com/cie404S1Rr1c/?ref=app
2nd Mar 2018, 4:46 AM
777
777 - avatar
+ 1
In Python, you have an id() function to help you. x = 1 print(id(x)) # prints memory location of x
28th Feb 2018, 6:12 PM
777
777 - avatar
+ 1
hex is format from id, but id is only identical number and not the address in memory)
1st Mar 2018, 3:06 PM
Michael
Michael - avatar
0
I think for id is only identical number, but please in memory save in hexadecimal format?!..
28th Feb 2018, 6:28 PM
Michael
Michael - avatar