Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/data/messages/c/consider-using-f-string/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
menu = ('eggs', 'spam')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
menu = ('eggs', 'spam')
from string import Template
menu = ('eggs', 'spam', 42.42)


order = "%s and %s" % menu # [consider-using-f-string]

new_order = "{1} and {0}".format(menu[0], menu[1]) # [consider-using-f-string]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
order = "%s and %s" % menu # [consider-using-f-string]
new_order = "{1} and {0}".format(menu[0], menu[1]) # [consider-using-f-string]
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + "and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = "and ".join(menu)
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2]) # [consider-using-f-string]
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2]) # [consider-using-f-string]
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, thanks for introducing me to the ¤ sign!

5 changes: 5 additions & 0 deletions doc/data/messages/c/consider-using-f-string/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
menu = ('eggs', 'spam')

order = f"{menu[0]} and {menu[1]}"

new_order = f"{menu[1]} and {menu[0]}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
order = f"{menu[0]} and {menu[1]}"
new_order = f"{menu[1]} and {menu[0]}"
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"