string identity and comparison

Jean-Michel Pichavant jeanmichel at sequans.com
Thu Dec 16 09:52:50 EST 2010


bruno.desthuilliers at gmail.com wrote:
> On 16 déc, 12:55, Jean-Michel Pichavant <jeanmic... at sequans.com>
> wrote:
>   
>> id('foo')
>> 3082385472L
>> id('foo')
>> 3082385472L
>>
>> Anyone has that kind of code ?
>>     
>
> 2 points:
>
>
> 1- an id is only valid for the lifetime of a given object - when the
> object has been collected, the id can be reused for another object.
>
>   
that's exactly what happened in my example, the 2 'foo' are not the same 
object actually, the fact that the 2 successive id() calls return the 
same value is implementation specific.
Thanks for pointing that out, I didn't realize in the first place.

JM



More information about the Python-list mailing list