[Tutor] Equality of numbers and Strings

Karim karim.liateni at free.fr
Mon Jan 10 17:07:44 CET 2011

Hello All,

I am not a beginner in Python language but I discovered a hidden 
property of immutable elements as Numbers and Strings.

s ='xyz'
 >>> t = str('xyz')

 >>> id(s) == id(t)

Thus if I create 2 different instances of string if the string is 
identical (numerically).
I get the same object in py db. It could be evident but if I do the same 
(same elements) with a list it
will not give the same result. Is-it because of immutable property of 
strings and numbers?


More information about the Tutor mailing list