2 ms·
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(s
by patrec 6y ago
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.