[Pythonmac-SIG] string ids

David Hostetler negativesum at gmail.com
Mon Dec 29 17:21:12 CET 2008


see:  http://docs.python.org/reference/expressions.html#id24

"Due to automatic garbage-collection, free lists, and the dynamic
nature of descriptors, you may notice seemingly unusual behaviour in
certain uses of the is operator, like those involving comparisons
between instance methods, or constants. Check their documentation for
more info."


As for teaching this issue, I would imagine that the appropriate
distinction needs to be made between 'is' as a built-in operator that
performs object identity comparison, vs. lexicographical comparison.


Also:
http://docs.python.org/library/stdtypes.html#comparisons
http://docs.python.org/reference/expressions.html#comparisons


On Mon, Dec 29, 2008 at 11:09 AM, Feat <jf at ai.univ-paris8.fr> wrote:
> At 16:59 +0100 29/12/08, Ronald Oussoren wrote:
>>Because strings aren't stored as unique objects. That is, there is no guarantee whatsoever that 'string1 == string2' implies 'string1 is string2'.
>
> Optimization, uh? Okay, that settles it: thanks!
>
> --
> Jym Feat ~ Paris FR 75018
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>


More information about the Pythonmac-SIG mailing list