[issue28481] Weird string comparison bug

Eryk Sun report at bugs.python.org
Thu Oct 20 00:33:01 EDT 2016


Eryk Sun added the comment:

Interning of strings is an implementation detail for the efficient storage of variable and attribute names. A string with ':' in it cannot be a variable or attribute name and thus is not interned. But you don't need to know which strings are interned or why they're interned because correct Python code should never compare strings by identity. Use an equality comparison, e.g. (var2 == ':bb'). Generally identity comparisons are of limited use in Python, such as checking for a singleton object such as None.

----------
nosy: +eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28481>
_______________________________________


More information about the Python-bugs-list mailing list