when comparing two strings in python, it works fine and when comparing a string
object with a unicode
object it fails as expected however when comparing a string
object with a converted unicode (unicode --> str)
object it fails
A Demo:
Works as expected:
>>> if 's' is 's': print "Hurrah!"
...
Hurrah!
Pretty much yeah:
>>> if 's' is u's': print "Hurrah!"
...
Not expected:
>>> if 's' is str(u's'): print "Hurrah!"
...
Why doesn't the third example work as expected when both the type's are of the same class?
>>> type('s')
<type 'str'>
>>> type(str(u's'))
<type 'str'>