>>> import math >>> print "{} {!s} {!r}".format(math.pi, math.pi, math.pi) 3.14159265359 3.14159265359 3.141592653589793
When is !sinside {}significant?
!s
{}
Or, in other words, when do you call str()in an argument format()meaningful?
str()
format()
Whenever a printable type implements __format__inappropriately for your purpose. In this case, you can use !sor !r(and I think there is even !a) to indicate an alternative formatter.
__format__
!r
!a
Of course, you won’t need to print floating point numbers, but probably for custom types.