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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com