Set all string declarations using f-strings
See original GitHub issueOnce Python 3 support is in, we should port string declaration to using f-strings.
f-strings are much easier to read. for example:
>>> name = "Eric"
>>> age = 74
>>> f"Hello, {name}. You are {age}."
'Hello, Eric. You are 74.'
Can be used in function calls:
>>> def to_lowercase(input):
... return input.lower()
>>> name = "Eric Idle"
>>> f"{to_lowercase(name)} is funny."
'eric idle is funny.'
There are also much faster then %s
and str.format()
This would make a line such as the following, much easier to read:
More details here: https://www.python.org/dev/peps/pep-0498/
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (18 by maintainers)
Top Results From Across the Web
Python f-String Tutorial – String Formatting in ... - freeCodeCamp
When using f-Strings to display variables, you only need to specify the names of the variables inside a set of curly braces {}...
Read more >A Guide to Formatting with f-strings in Python - CIS Sandbox
To use formatted string literals, begin a string with f or F before the opening quotation mark or triple quotation mark in a...
Read more >f-strings in Python - GeeksforGeeks
The idea behind f-strings is to make string interpolation simpler. To create an f-string, prefix the string with the letter “ f ”....
Read more >Python 3's f-Strings: An Improved String Formatting Syntax ...
As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less...
Read more >4 Tricks to Use Python F-strings More Efficiently
Thus, the print statements are much more powerful with string interpolation… ... F-strings make it quite simple to place these separators ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just been thinking about this, the best approach (and easier for you) might be to backup your current repository / work
cp -r keylime keylime_fstrings
Go into
keylime
and switch the master branch, grab the changes and merge them into your repo and push them:git fetch upstream
git merge upstream/master master
git push origin master
After that create a new branch:
git checkout -b frstings
Then open two editors, one in
keylime
and one inkeylime_fstrings
In a terminal and the original directory
keylime_fstrings
with your changes rungit status
or better stillgit diff
and note your changes. Now copy and paste those changes from your editor showingkeylime_fstrings
into the editor showingkeylime
Once all of that is complete, you can then just push your branch and make a pull request.
For
upstream
to work ingit fetch upstream
you will need a.git/config
like this:sounds good! @lukehinds. I’ll block the time 😃