2 ms·
I know I'm one who keeps having to go back to add the 'f' prefix to my strings. I lived through the many "from __future__ import" of late Python 2.x releases,
by eesmith 7y ago
I know I'm one who keeps having to go back to add the 'f' prefix to my strings.
I lived through the many "from __future__ import" of late Python 2.x releases, so I know I can deal with a "all_fstrings" solution during a migration period.
Looking through my code I see things like:
r"[a-zA-Z][a-zA-Z0-9]{3}"
which, if interpreted as an f-string, would change the regexp but not cause it to not compile - the breakage would be downstream.
I suspect there's some places where existing code which uses .format() will still work, with all-f-strings, like:
>>> name = "eesmith"
>>> print("Who? {name}".format(name=name))
Who? eesmith
>>> print(f"Who? {name}".format(name=name))
Who? eesmith
but cause subtle errors because of the double string formatting:
>>> name = "{x}"
>>> print("Who? {name}".format(name=name))
Who? {x}
>>> print(f"Who? {name}".format(name=name))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'x'
I'm glad I don't have to make this decision.