Why the python shows ambiguous results for is
keyword when used against string datatype?
Following code snippet describes my question
>>> l1='shrey'
>>> l2='shrey'
>>> l1 is l2
True
>>> l1='shrey saraswat'
>>> l2='shrey saraswat'
>>> l1 is l2
False
Shouldn't it be same at both place?
Either True
and True
or False
and False
This question looks similar to 'is' operator behaves differently when comparing strings with spaces . But i wasn't able to find the exact answer there. I just want to know the why and how scenario for the case discussed above.