I know Python interns certain strings and creates a hash if the string starts with a letter or an underscore and only contains letters, underscores, or numbers as seen in Martijn Pieters codementor interview.
When assigning individually s = "$foo"
and s1 = "$foo"
s is s1
returns False
as expected but using s, s1 = "$foo", "$foo"
s is s1
returns True
.
Why does python behave differently using the different assignments?
In [1]: s, s1 = "$foo", "$foo"
In [2]: s is s1
Out[2]: True
In [3]: s1 = "$foo"
In [4]: s = "$foo"
In [5]: s is s1
Out[5]: False