How to get the actual address of a object

mujunshan at gmail.com mujunshan at gmail.com
Fri Oct 24 10:25:14 EDT 2008


On 10月24日, 下午1时10分, "James Mills" <prolo... at shortcircuit.net.au>
wrote:
> On Fri, Oct 24, 2008 at 2:58 PM,  <mujuns... 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"

Thank you,James.
My original idea was to study all the contents of any object. I can do
it by using module ctypes.



More information about the Python-list mailing list