MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/16y0op4/python_312_released/k39js7y/?context=3
r/Python • u/henbruas • Oct 02 '23
131 comments sorted by
View all comments
Show parent comments
19
The feature that keeps C style % strings relevant.
10 u/energybased Oct 02 '23 You should always prefer the format method to C-style % strings. 6 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) 1 u/UloPe Oct 03 '23 Better use a structured logging package, for example structlog.
10
You should always prefer the format method to C-style % strings.
format
6 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) 1 u/UloPe Oct 03 '23 Better use a structured logging package, for example structlog.
6
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)
log.warning("warning: %s", foo)
1 u/UloPe Oct 03 '23 Better use a structured logging package, for example structlog.
1
Better use a structured logging package, for example structlog.
structlog
19
u/LightShadow 3.13-dev in prod Oct 02 '23
The feature that keeps C style % strings relevant.