1 hour ago · Tech · hide · 0 comments

Python A-Z is a blog series about Python. Each day, I share insights, ideas and examples for different parts of Python development that match with the letter of the day. Blaugust is an annual blogging festival in August where the goal is to write a blog post every day of the month. Programming languages have many ways to combine literal strings and variables. For a decade now, we in Python land have been able to enjoy the beauty and elegance of f-strings. f-string is a string that is prefixed with the letter f: string_type = 'f-string' print(f'This is a {string_type}') When you craft an f-string, you can evaluate Python code inside it by placing it inside curly braces `{ … }`. In addition to simply putting in a variable, there are a bunch of format specifications that allow further modification of the output. fstring.help has a really handy reference sheet for these but here are some that I use regularly. Padding numbers File browsers usually default to sorting alphabetically so if…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.