string identity and comparison

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Thu Dec 16 10:41:39 EST 2010


On 16 déc, 15:52, Jean-Michel Pichavant <jeanmic... at sequans.com>
wrote:
> bruno.desthuilli... 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.
>

been here, done that :-/




More information about the Python-list mailing list