[Python-Dev] Using logging in the stdlib and its unit tests

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Dec 8 20:42:00 CET 2010


 <skip <at> pobox.com> writes:

>     >>> logging.error("error 1 2 3 %s" % "yup")
>     ERROR:root:error 1 2 3 yup
>     >>> logging.error("error 1 2 3 %s", "yup")
>     ERROR:root:error 1 2 3 yup
> 
> The second form should be preferred in library code as long as the format
> string expansion is deferred until after the test is made to emit the
> message.

Yes, and the string expansion normally is deferred to happen as late as possible.

Regards,

Vinay




More information about the Python-Dev mailing list