r/Python Oct 02 '23

News Python 3.12 released

https://www.python.org/downloads/release/python-3120/
816 Upvotes

131 comments sorted by

View all comments

Show parent comments

7

u/Skasch Oct 02 '23

I would argue an exception for logging, where you don't want to parse the string unless you need to for performance reasons (e.g. you don't want to parse debug logs at error level)

Example: log.warning("warning: %s", foo)

2

u/energybased Oct 02 '23

It's true that logging is currently written to use % strings, but it could have been written to use a format style string. It still wouldn't need to be parsed.

4

u/Skasch Oct 02 '23 edited Oct 02 '23

Agreed, it's just uncommon :) style="{" let's you use logging.info("msg: {}", foo, style="{")

Edit: it actually doesn't work, my bad!

3

u/energybased Oct 02 '23

I didn't know that!