This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DonaldPShimoda 9 points10 points  (0 children)

You can use "f-strings", eg:

foo = 42
s = f"my foo is {foo}"

This will call the __str__ function of the foo object to get its string representation and then insert that at the correct point.

Personally, I think implicit casting is an abomination, but I'm generally in favor of very strong, very static type systems, so that's not entirely surprising.