A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-October/092429.html below:

[Python-Dev] transitioning from % to {} formatting

[Python-Dev] transitioning from % to {} formattingVinay Sajip vinay_sajip at yahoo.co.uk
Thu Oct 1 08:15:35 CEST 2009
Antoine Pitrou <solipsis <at> pitrou.net> writes:

> Why not allow logging.Formatter to take a callable, which would in turn call
> the callable with keyword arguments?
> 
> Therefore, you could write:
>    logging.Formatter("{asctime} - {name} - {level} - {msg}".format)
> 
> and then:
>    logging.critical(name="Python", msg="Buildbots are down")

This seems perhaps usable for a Formatter instantiation (infrequent) but a
problem for the case where you want to convert format_str + args -> message
(potentially frequent, and less readable). Another problem is that logging
calls already use keyword arguments (extra, exc_info) and so backward
compatibility might be compromised. It also feels like passing a callable could
encourage patterns of usage which restrict our flexibility for future changes:
we want for now to just allow choosing between % and {}, but a callable can do
anything. That's more flexible, to be sure, but more specialized formatting
requirements are already catered for using e.g. the PercentMessage/BraceMessage
approach.

Regards,

Vinay Sajip

More information about the Python-Dev mailing list

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