Nick Coghlan <ncoghlan <at> gmail.com> writes: > Oh, I see what you meant now - you were pointing out that lazy > formatting APIs (such as logging) already don't work properly for > alternative formatting mechanisms (such as string.Template). > Logging doesn't work automatically with string.Template as it pre-dates string.Template, but it can be made to work without too much trouble: (a) Subclass Formatter to use $-formatting instead of %-formatting for e.g. the lines written to log files, and (b) Use a class like DollarMessage which I mentioned elsewhere in this thread, to format logging call format strings and arguments. Both of these approaches will also work for {}-formatting. The present thread really started out with a view to suggesting that the stdlib start adopting {}-format as "native", rather than %-format. Would it be helpful if I added a section to the Python docs about how to use alternative formatting systems with logging? Regards, Vinay Sajip
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4