John K Masters <[EMAIL PROTECTED]> writes: > > OK fiddling around with this and reading the docs I tried:- > a = 'qqqqqqqqqq' #10 q's > b = 'qqqqqqqqqq' #10 q's > a is b > true > c = 'q' * 10 > c > 'qqqqqqqqqq' #10 q's > d = 'q' * 10 > d > 'qqqqqqqqqq' #10 q's > c is d > false > > So from what I've read "==" tests for equivalence, "is" tests for identity but > that does not explain the behaviour above. >
There's nothing especially to be explained, other than "that's the way the compiler does it". Two equal string literals might be the same object or they might not be. It's a language implementation detail. -- http://mail.python.org/mailman/listinfo/python-list