Location of variables
Fredrik Lundh
fredrik at effbot.org
Wed Jan 17 17:42:14 EST 2001
Grzegorz Dostatni wrote:
> Is there a way in Python to find out the memory location of variables?
> Something like
>
> def s():
> pass
>
> print s
>
> will print the type and memory location of s.
> Is there something like that if s is just a simple variable?
> (int for example).
>
> I need it to help me debug a problem...
print type(s)
print id(s)
footnote: objects don't have addresses, they have identities.
the identity happens to be a memory address in CPython, but
that's an implementation detail. more info here:
http://effbot.org/guides/python-objects.htm
hope this helps!
Cheers /F
More information about the Python-list
mailing list