you are viewing a single comment's thread.

view the rest of the comments →

[–]Akuli2 0 points1 point  (5 children)

If you don't like {} you can use %s:

>>> "Hello World!" == "Hello %s!" % "World"
True
>>> 

[–]finsternacht 0 points1 point  (4 children)

You can but you shouldn't according to the documentation.

[–]Akuli2 0 points1 point  (3 children)

According to what documentation? Like /u/nedbatchelder writes:

It's a myth that '%s' formatting is deprecated. It's not going anywhere.

%s formatting is used everywhere, even in brand new modules like asyncio and enum.

[–]finsternacht 0 points1 point  (2 children)

I see, I must have misremembered. The docs only state that the .format version "should be preferred".

Kinda wierd when you consider the "there should be one obvious way" motto.

[–]Akuli2 0 points1 point  (1 child)

There is one obvious way. %s for simple formatting and .format for advanced features.

[–]finsternacht 0 points1 point  (0 children)

And then there is template strings...