[Python-Dev] [Python-checkins] r88385 - python/branches/py3k/Doc/whatsnew/3.2.rst

Nick Coghlan ncoghlan at gmail.com
Thu Feb 10 14:00:08 CET 2011


On Thu, Feb 10, 2011 at 7:20 PM, raymond.hettinger
<python-checkins at python.org> wrote:
> +The :func:`logging.basicConfig` set-up function gained a *style* argument to
> +support three different types of string formatting.  It defaults to "%" for
> +traditional %-formatting, can be set to "{" for the new :meth:`str.format` style, or
> +can be set to "$" for the shell-style formatting provided by
> +:class:`string.Template`.  The following three configurations are equivalent::
> +
> +    >>> from logging import basicConfig
> +    >>> basicConfig(style='%', format="%(name)s -> %(levelname)s: %(message)s")
> +    >>> basicConfig(style='{', format="{name} -> {levelname} {message}")
> +    >>> basicConfig(style='$', format="$name -> $levelname: $message")

It may be worth noting here that:
1. the "style" parameter also exists for logging.Formatter objects
2. it only applies to the output formatting for output, individual
logging calls are still constrained to using %-formatting by backwards
compatibility issues

(Especially point 2 - I briefly forgot that distinction myself, and I
helped review this feature when Vinay added it)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list