f2format
is an intelligent, yet imperfect, solution for f-string literal compatibility. You may write f-string literals in Python 3.6 flavour, and compile to a compatible version for end-users to run, just like Babel
for JavaScript.
f2format
shall replace f-string literals with str.format
methods, whilst maintaining the original layout of source code. You can simply use
f2format /path/to/the/file_or_directory
which will rewrite all Python files in place. For instance,
```python
var = f'foo{(1+2)*3:>5}bar{"a", "b"!r}boo'
var = ('foo{:>5}bar{!r}boo').format(((1+2)*3), ("a", "b")) ```
String concatenation, conversion, format specification, multi-lines and unicodes are all treated right. Also, f2format
will archive original files in case there're any syntax breaches.