> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Replace Interpolation With Fstring

#### Sourcery refactoring id: `replace-interpolation-with-fstring`

#### Description

Replace usage of string interpolation `%` operator with f-strings

#### Before

```python
print("Good %s, %s %s" % (time_of_day, first_name, last_name))
```

#### After

```python
print(f"Good {time_of_day}, {first_name} {last_name}")
```

#### Explanation

The
[Python documentation](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting)
notes that using the `%` operator to format strings can lead to 'a variety of
quirks that lead to a number of common errors'.

Python added f-strings in version 3.6, with
[PEP 498](https://www.python.org/dev/peps/pep-0498/). F-strings are a flexible
and powerful way to format strings. They make the code shorter and more
readable, since the code now looks more like the output.

Note that for the moment this refactoring only supports replacement of
formatting that uses the `%s` operator.
