Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Replace string.format() with fstrings #117

Merged
merged 1 commit into from
Jun 29, 2021
Merged

Replace string.format() with fstrings #117

merged 1 commit into from
Jun 29, 2021

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Jun 28, 2021

Python 3.6 introduced a new way of formatting strings using so-called f-strings. This made formatted strings more readable and concize.

Instead of writing

who = "world"
print("Hello {who}".format(who=who))

we can write

who = "world"
print(f"Hello {who}")

This PR consistently replaces string.format with f-strings.

Signed-off-by: Olga Bulat [email protected]

@obulat obulat requested a review from a team as a code owner June 28, 2021 13:24
@obulat obulat requested review from zackkrida and krysal June 28, 2021 13:24
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you also switched simple cases like VAR_NAME + 'test-123' to f'{VAR_NAME}test-123'; the consistency is appreciated.

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so much better, thank you!

@obulat obulat merged commit ead6951 into main Jun 29, 2021
@zackkrida zackkrida deleted the fstrings branch June 29, 2021 15:29
dhruvkb added a commit that referenced this pull request Jul 3, 2021
dhruvkb added a commit that referenced this pull request Jul 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants