I hope you enjoyed learning about #Python string formatting using the `format()` method
Be sure to follow me for more Python tips and tricks! 🐍🔥
Latest Posts by
The `format()` method also allows you to set the string alignment.
Here are a few examples:
If you put integers within the curly braces, then you can control which argument goes where (although this is probably the most confusing way to do it)
You can also just use named parameters and skip the dictionary:
You can also use a #Python dictionary when using the `format()` method to use named parameters:
What happens when you have too many braces, though?
Well, you get an error! 🐍⚠
When you use `format()`, you still use curly braces in your string. Then you pass in the same number of arguments as you have braces:
Before #Python f-strings, you had to call format()
Sometimes you still do, so it's good to learn about it!
Check out this mini thread on the topic
🐍🧵👇
Did you know you can create your own custom iterators in #Python?
All you need to do is write your own custom `__iter__` and `__next__` methods
Here's an example:
I have started posting #Python Pop Quizzes in my newsletter and on my blog @mousevspython 🐍❓
These quizzes include the answers too!
#Python lambda craziness 🐍🤪
It's lambdas all the way down!
How to check if a string is printable or not in #Python 🐍🤯
There are several different ways to create an empty dictionary with #Python
Here are two of them:
How to use #Python and a defaultdict to return a custom message if the key does not exist in the dictionary 🐍🚀
Want to grab just the filename from a path in #Python? You can do that too with pathlib! 🐍🔥
Need to get the parent folder of a path in #Python? Use pathlib! It makes working with paths so easy!
Here's a link to see all my products:
driscollis.gumroad.com/
#Python Tax Day Sale is on! Save 30% of any of my Python books or courses using the following coupon code: TAXDAY26
Note: The photo below does not show all my books!
There are lots of #Python GUI frameworks. Have you tried out dearpygui yet?
Here's a quick demo they have provided:
I have been a #Python programmer for 20 years now!
I have used Python for all the following and more:
🐍 Automation
🐍 GUIs
🐍 PDF creating, scraping, etc
🐍 Excel
🐍 Login scripts
🐍 Testing C++ / Python
🐍 Websites
🐍 and much more
Ask me anything!
Learn more here:
openai.com/index/opena...
Astral, the company behind the amazing Ruff, uv, and ty applications, is being acquired by OpenAI
What do you think about this new update?
What have you used a #Python async comprehension for lately? 🐍❓
Did you know that you can check if an instance is one of multiple classes in #Python?
Here's how to do it:
The Mouse vs Python blog is back on the top 60 #Python blog list again this year along with many of my other friends!
bloggers.feedspot.com/python_blogs