You seem to expect id(f)
to display the same number as if you just print out f
. This is not the case, as shown in this example:
>>> f
<__main__.Foo object at 0x10929df10>
>>> id(f)
4448706320
>>> w
<weakref at 0x10928cfc8; to 'Foo' at 0x10929df10>
>>> id(w)
4448636872
The other thing that didn't show up in your example is that in the output of w
, the location of 'Foo'
is in hexadecimal.
>>> print 0x10929df10
4448706320
Using the numbers from what you gave us:
>>> print 0x0225DF30
36036400
So you can see that the numbers are actually the same; it's just that it's displaying in hex in one place and in decimal in the other.