In Python format (f-string) strings, what does !r mean? [duplicate] In Python format (f-string) strings, what does !r mean? [duplicate] python python

In Python format (f-string) strings, what does !r mean? [duplicate]


It just calls the repr of the value supplied.

It's usage is generally not really needed with f-strings since with them you can just do repr(self.radius) which is arguably more clear in its intent.

!r (repr), !s (str) and !a (ascii) were kept around just to ease compatibility with the str.format alternative, you don't need to use them with f-strings.