Say we have:
f = "The object named '{}' is corrupted."
s = "The object named 'my_object' is corrupted."
s
is equal to f.format("my_object")
. If we didn't know that, how could we check if s
can be generated by formatting f
? Is there a function to do that in the standard library?
This can be done using regex but we'd have to reimplement the logic of how format
works (e.g., curly braces are replaced with any string, etc). This is why I'd like to know if there's a way to use the same logic that str.format
uses.