Re:Python 3's F-Strings: An Improved String Formatting Syntax
by patrec on Thursday January 21, 2021 @02:42AM
(#25856504)
Yes, you can work around some of the defects I mentioned by defining your own wrapper classe(s) and doing something like this:
f"Article: {fixformatting(somestr):20} Price: {fixformatting(price):5.3}"
Apart from somewhat negating the main advantage of f-strings (relative conciseness) it does not allow you take into account surrounding string context and of course will not fix problems when you have values that contain objects that already have __format__ defined. Also, python being python, you now slowed everything down by an order of magnitude.
They are customizable on an object-to-be-formatted basis (__format__ special method).