string identity and comparison
Steve Holden
steve at holdenweb.com
Thu Dec 16 07:28:15 EST 2010
On 12/16/2010 6:55 AM, 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
>
>>> id("foo")
2146743808
>>> id ("f"+"o"+"o")
2146744096
>>>
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon 2011 Atlanta March 9-17 http://us.pycon.org/
See Python Video! http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list