John Salerno <[EMAIL PROTECTED]> wrote: >>>> a = 'this is longer' >>>> b = 'this is longer' >>>> a == b > True >>>> a is b > False >>>> > > In the above example, Python has created only one string called > 'hello' and both x and y reference it. However, 'this is longer' is > two completely different objects.
That is true when run interactively, but the behaviour changes again if you run it as a script: C:\Temp>type t.py a = 'this is longer' b = 'this is longer' print a is b C:\Temp>t True In short, two equal strings may or may not be identical and any code which makes assumptions based on observed behaviour is broken. If you want to be able to test identity on strings safely then use the 'intern()' builtin to get repeatable behaviour. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list