Re: How to get the actual address of a object

2008-10-24 Thread James Mills
On Sat, Oct 25, 2008 at 12:25 AM, <[EMAIL PROTECTED]> wrote: > Thank you,James. > My original idea was to study all the contents of any object. I can do > it by using module ctypes. You can simply just query it's attributes. Use __dict__ or dir(obj) Example: >>> x = 10 >>> dir(x) ['__abs__', '

Re: How to get the actual address of a object

2008-10-24 Thread mujunshan
On 10月24日, 下午1时10分, "James Mills" <[EMAIL PROTECTED]> wrote: > On Fri, Oct 24, 2008 at 2:58 PM, <[EMAIL PROTECTED]> 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

Re: How to get the actual address of a object

2008-10-23 Thread James Mills
On Fri, Oct 24, 2008 at 2:58 PM, <[EMAIL PROTECTED]> 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

Re: How to get the actual address of a object

2008-10-23 Thread James Mills
On Fri, Oct 24, 2008 at 2:51 PM, <[EMAIL PROTECTED]> 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 separa

Re: How to get the actual address of a object

2008-10-23 Thread mujunshan
On 10月24日, 下午12时51分, [EMAIL PROTECTED] wrote: > Hi,I have a strange idea:is there any way to get memory address of a > object. > > For example: > > i = 10 > > addr = get_address(i) > address will be assigned a integer which is pointer of object > i,then

How to get the actual address of a object

2008-10-23 Thread mujunshan
Hi,I have a strange idea:is there any way to get memory address of a object. For example: i = 10 addr = get_address(i) address will be assigned a integer which is pointer of object i,then I want to recast addr into another integer: j