- 1
id()
In Python 3, what is this id() function returning?
4 Respostas
+ 3
id() gives you memory address of the variable.in python when you create something variable , function,object or whatever everything stores in memory block.each of variable,function has different memory block which can acess using using it's memory address.
x=5
print(id(x)) gives you memory address of the x variable.
+ 1
it gives an specific id to an object for identification.
0
After experimenting, my observation is that
id(n+1) - id(n) = 16
https://code.sololearn.com/c0hIItv4yn4H/?ref=app
0
When I redefine A from 3 to 4
its id increases by 16
So I'm not so sure about "specific id" or "memory address"
Looks like it's more about the value itself.
https://code.sololearn.com/c0hIItv4yn4H/?ref=app