Would somebody please be able to explain the following behaviour in Python:
>>> 'a' * 20 is 'aaaaaaaaaaaaaaaaaaaa'
True
>>> 'a' * 21 is 'aaaaaaaaaaaaaaaaaaaaa'
False
I would expect the second case to be also True
. This example is taken from the wtfpython repo, which is a collection of snippets with "surprising" behaviours. There is an open issue about a missing explanation for this particular snippet, though given the context I assume this has to do with "interning" strings. Your explanations would go towards submitting a PR, thanks!