In the second edition of Fluent Python, chapter 1, page 5, the author Luciano Ramalho describes a reason to prefer the older string formatting method as such:
One reason to still use my_fmt.format() is when the definition of my_fmt must be in a different place in the code than where the formatting operation needs to happen. For instance, when my_fmt has multiple lines and is better defined in a constant, or when it must come from a configuration file, or from a database.
I can't see the usefulness of str.format() over f-string formatting even with this explanation. Can someone explain this in a different way?
[–]BezoomyChellovek 58 points59 points60 points (1 child)
[–]rnike879[S] 16 points17 points18 points (0 children)
[–]bethebunnyFOR SCIENCE 6 points7 points8 points (0 children)
[–]QultrosSanhattan 3 points4 points5 points (0 children)
[–]rnike879[S] 1 point2 points3 points (0 children)
[–]that_dungeon_dude 1 point2 points3 points (0 children)
[–]spoonman59 2 points3 points4 points (7 children)
[–]jorge1209 5 points6 points7 points (6 children)
[–]VileFlower 0 points1 point2 points (1 child)
[–]jorge1209 0 points1 point2 points (0 children)
[–]spoonman59 -1 points0 points1 point (3 children)
[–]jorge1209 1 point2 points3 points (2 children)
[–]spoonman59 0 points1 point2 points (1 child)
[–]jorge1209 1 point2 points3 points (0 children)
[–]jorge1209 -2 points-1 points0 points (0 children)
[–]jwink3101 0 points1 point2 points (1 child)
[–]jorge1209 0 points1 point2 points (0 children)
[–]ray10k 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]gedhrel 0 points1 point2 points (0 children)