On Thu, Oct 29, 2009 at 8:43 PM, metal <metal...@gmail.com> wrote: > '11' + '1' == '111' is well known. > > but it suprises me '11'+'1' IS '111'. > > Why? Obviously they are two differnt object. > > Is this special feature of imutable object?
It's an implementation detail of small strings without spaces and small numbers. You're more likely to reuse those values, so Python caches them. You shouldn't rely on it. It's not guaranteed to stay the same between different implementations, or even different versions of CPython. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list