[Python Tips] f-strings in Python 3.6 and why you should be using them
What are f-strings and why are they so awesome?
f-strings is a new streamlined way of formatting strings that came with Python 3.6. Traditionally you would format a string like this:
employee = 'Bob'
role = 'Manager'
company = 'Amazon'
print('{} is a {} at {}.'.format(employee, role, company))
With f-strings you can do the same this with the following code:
employee = 'Bob'
role = 'Manager'
company = 'Amazon'
print(f'{employee} is a {role} at {company}')
Expressions in f-string
You can use python expressions inside of your curly braces.
name = 'Dog Dog'
age = 4
print(f'{name} is {age * 7} in dog years')
Performance considerations
f-strings are fast, twice as fast as format() as they are stored as bytecode.
Why you should vote me as witness
Witness & Administrator of four full nodes
X48EJ
My recent popular posts
STEEM, STEEM Power, Vests, and Steem Dollars. wtf is this shit?
The truth and lies about 25% curation, why what you know is FAKE NEWS
WTF is a hardware wallet, and why should you have one?
GINABOT - The Secret to your Sanity on Steemit
How to calculate post rewards
Use SSH all the time? Time for a big boy SSH Client
How to change your recovery account
How curation rewards work and how to be a kick ass curator
Markdown 101 - How to make kick ass posts on Steemit
Work ON your business, not in your business! - How to succeed as a small business
You are not entitled to an audience, you need to earn it!
How to properly setup SSH Key Authentication - If you are logging into your server with root, you are doing it wrong!
Building a Portable Game Console
Leave [Python Tips] f-strings in Python 3.6 and why you should be using them to:
Read more #programming posts
Best Posts From Marky
We have not curated any of themarkymark's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Marky
- Tan Stack Scanner
- New LLM benchmark: llmtester
- Receive proactive alerts when your openclaw instance is unavailable
- My two favorite Openclaw hacks
- If you are running openclaw, make sure you are updated.
- Some things I wish someone told me when I setup Openclaw
- If you are running openclaw, make sure you are updated.
- Hive Hot or Not improvements
- Hive Hot or Not!
- Block Bandits update