Closed janine9vn closed 3 years ago
Hey, I agree that this should be a tag and you've done a nice job of showcasing a few major features. 👍. I also think the !r
modifier which shows the __repr__
of an object should be featured.
So, for showcasing the repr I think this will work:
repr_str = "Spam \n Ham"
print(f"{repr_str!r}") # You can easily call repr on objects within an f-string
Results:
'Spam \n Ham'
If we're good with this, I can work to get this tag written this weekend
This is now a thing! View the tag by running this in bot-commands: !string-formatting
Tag Name
!string-formatting
What kind of content should the tag include?
The Python String Formatting Mini Language is a powerful tool once people discover f-string. You can see the specification here: https://docs.python.org/3/library/string.html#format-specification-mini-language I would also like to include this resource and it breaks it down in a very readable manner: https://pyformat.info/
Ideally, this tag would showcase some of the more obviously useful ones and then link to the full spec. The ones I think should be included:
Results: