Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added guidance about using f-strings #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Onager
Copy link
Contributor

@Onager Onager commented Oct 25, 2022

No description provided.

* Use the [f-strings](https://peps.python.org/pep-0498/) instead of the `format()` function or %-style of formatting strings wherever possible.
* The codebases are still being migrated to this style, so there may be some stray use of other styles around.
* Use format specifiers with typing, for example, `f'{example:s}'` for increased clarity about the type and formatting of different variables.
* If referencing a string literal in a f-string, use double quotes for the literal. For example: `f'String in dict: {dict["first"]}'`
Copy link
Member

Choose a reason for hiding this comment

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

Would recommend using a helper variable here, harder to debug if dict["first"] raises

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants