Inverse of id()?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon May 21 03:58:03 EDT 2007


En Sun, 20 May 2007 22:19:01 -0300, Ian Clark <turbana at gmail.com> escribió:

> On 5/20/07, Michael Hoffman <cam.ac.uk at mh391.invalid> wrote:
>>  [snip]
>> That's not what I get:
>
> That's because you didn't have 'del a'.
>
> Now I tried this in the shell and got different id's for a and b, but
> when I typed it into a file and ran from there the id's where always
> the same. Must have something to do with other programs allocating
> space faster than I can type everything out (I do have a few processes
> going). Interesting.

The point is, as id() is related to the object memory address, and memory  
may be reused, two objects (*NOT* simultaneously alive!!!) may return the  
same id().
Perhaps in some circunstances it's easier to show than in others, but it  
happens, so unless one is absolutely sure that the object is still alive,  
going back from its id to the original object is dangerous.

-- 
Gabriel Genellina




More information about the Python-list mailing list