Search This Blog

Python: string comparison == or is

Use == when comparing values and is when comparing identities.
>>> a = 'abc'
>>> b = ''.join(['a', 'b', 'c'])
>>> a == b
True
>>> a is b
False

see also

No comments:

Post a Comment