The Python docs for str.swapcase() say:
Note that it is not necessarily true that
s.swapcase().swapcase() == s
.
I\'
This is the case when multiple letters are lower cases of the same letter.
For example, the micro character µ
(U+00B5) and the mu character μ
(U+03BC):
>>> u'\xb5'.swapcase()
u'\u039c'
>>> u'\u03bc'.swapcase()
u'\u039c'
The two are different characters, but their uppercase counterparts are the same. This means that when str.swapcase()
is applied, they return the same character. However, doing this again can't (and won't) return both letters.
>>> u'\xb5'.swapcase().swapcase()
u'\u03bc'