Logging messages with dictionary args in Python 2.4b1 leads to exception

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Oct 20 16:42:25 EDT 2004


> I thought a logging API was usually trying to do costly things only when 
> it knows it has to. You /could/ do that, but since it doesn't come for 
> free - why not first do the check if you will actually log this message?

Right.
 
> I'd simply say that constructing a log message from arguments is such a 
> common thing that it is worth providing efficient API support for it. And 
> I think it's truely counter-pythonic to prevent the usage of dictionaries 
> at this point.

Patch checked into CVS. Now:

>>> logging.warn('%(string)s and the %(number)d dwarves', {'string':
'Snow White', 'number':7})

gives

WARNING:root:Snow White and the 7 dwarves

Regards,


Vinay



More information about the Python-list mailing list