How to get the actual address of a object
James Mills
prologic at shortcircuit.net.au
Fri Oct 24 01:00:20 EDT 2008
On Fri, Oct 24, 2008 at 2:51 PM, <mujunshan at gmail.com> wrote:
> Hi,I have a strange idea:is there any way to get memory address of a
> object.
id(obj)
Example:
>>> x = 10
>>> id(x)
134536908
But this probably (most likely) isn't it's address in memory
but more it's unique identifier that separates it from every
other object in memory.
> j = cast(addr,<type int>)
You can't do this in Python afaik nor would you want to.
If you simply want to copy an object, do this:
>>> x = 10
>>> y = x
>>> id(x)
134536908
>>> id(y)
134536908
>>>
cheers
James
--
--
-- "Problems are solved by method"
More information about the Python-list
mailing list