How to determine an ID on Python?
I heard that the same strings have the same IDs like below:
>>>list1=[1,2,'aaa','bbb']
>>>list2=[3,4,'aaa','bbb']
>>>id(list1[2])
12345
>>>id(list2[2])
12345
but the following case does not hold the rule:
>>>list1=[1,2,'Hello World','bbb']
>>>list2=[3,4,'Hello World','bbb']
>>>id(list1[2])
12345
>>>id(list2[2])
12367
How are they different from each other?
Added
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> list1 = [1, 2, 'aaa', 'bbb']
>>> list2 = [2, 3, 'aaa', 'bbb']
>>> id(list1[2])
4511557072
>>> id(list2[2])
4511557072
>>> list3 = [1, 2, 'Hello World', 'bbb']
>>> list4 = [2, 3, 'Hello World', 'bbb']
>>> id(list3[2])
4511542272
>>> id(list4[2])
4511542368