[Python-ideas] f-string literals by default?

Neil Schemenauer nas-python-ideas at arctrix.com
Tue Dec 5 16:19:23 EST 2017

I think most people who have tried f-strings have found them handy.
Could we transition to making default string literal into an
f-string?  I think there is a smooth migration path.

f-strings without embedded expressions already compile to the same
bytecode as normal string literals.  I.e. no overhead.  The issue
will be literal strings that contain the f-string format characters.

We could add a future import, e.g.

    from __future__ import fstring_literals

that would make all literal strings in the module into f-strings.
In some future release, we could warn about literal strings in
modules without the future import that contain f-string format
characters.  Eventually, we can change the default.

To make migration easier, we can provide a source-to-source
translation tool.  It is quite simple to do that using
the tokenizer module.

More information about the Python-ideas mailing list