Python: Why does (“hello” is “hello”) evaluate as True? [duplicate]

Python (like Java, C, C++, .NET) uses string pooling / interning. The interpreter realises that “hello” is the same as “hello”, so it optimizes and uses the same location in memory.

Another goodie: "hell" + "o" is "hello" ==> True

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)