is
is identity testing, ==
is equality testing. what happens in your code would be emulated in the interpreter like this:
>>> a = 'pub'
>>> b = ''.join(['p', 'u', 'b'])
>>> a == b
True
>>> a is b
False
so, no wonder they're not the same, right?
In other words: a is b
is the equivalent of id(a) == id(b)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…