string identity and comparison

Jean-Michel Pichavant jeanmichel at sequans.com
Thu Dec 16 08:58:46 EST 2010


Jean-Michel Pichavant wrote:
> Fellows,
>
> I'd like to illutrate the fact that comparing strings using identity 
> is, most of the time, a bad idea. However I'm searching a short 
> example of code that yields 2 differents object for the same string 
> content.
>
> id('foo')
> 3082385472L
> id('foo')
> 3082385472L
>
> Anyone has that kind of code ?
>
> JM
>
a = 'foo'
b = '%s' % a
a is b
 >>> False


Yet another Auto replied thread from myself :-/

JM



More information about the Python-list mailing list