How to get the actual address of a object
James Mills
prologic at shortcircuit.net.au
Fri Oct 24 01:10:35 EDT 2008
On Fri, Oct 24, 2008 at 2:58 PM, <mujunshan at gmail.com> wrote:
> maybe id(x) can get it ,but how to cast it back into a object
You can't. Python is NOT C/C++/Java or whatever.
If you have a variable, x, and you want to "copy" it
to another variable, y. Use assignment.
Most (if not all) objects in python a referenced.
A lot of types are also immutable.
Describe your problem, perhaps we may be able to
provide you a "better" solution ? Can I statically re-cast
an object into a different type by getting the address
of another object .... is not a very good problem.
If you're after, coercing one type into another, for example:
>>> x = 2
>>> y = "2"
>>> z = int(y)
>>> x
2
>>> y
'2'
>>> z
2
>>>
cheers
James
--
--
-- "Problems are solved by method"
More information about the Python-list
mailing list