0

I hope that I was able to formulate the question well in the title. My question is, if I create variables a and b:

>>> a = 'hey'
>>> b = 'hey'

It turns out that these are identical objects, since

>>> a is b
True 

and

>>> id(a) == id(b)
True

But when I try the same thing with the string 'Baden-Württemberg';

>>> e = 'Baden-wüttemberg'
>>> c = 'Baden-wüttemberg'
>>> e is c
False
>>> id(e) == id(c)
False

What is the reason for this? Why does Python seem to store the same string in different ID addresses and not "alias" as it had done with 'hey'?

Thank you all. :)

0 Answers0