[Python-Dev] PEP282 and the warnings framework
Barry A. Warsaw
barry@zope.com
Thu, 16 May 2002 11:45:45 -0400
>> If I have a choice between writing:
>>
>> log.debug(
>> "HOME environment variable set to non-existent directory %s",
>> homedir
>> )
>
> with the mapping in my previous posting you would write
>
> log.debug(
> "HOME environment variable set to non-existent directory " + homedir
> )
>>>>> "A" == Aahz <aahz@pythoncraft.com> writes:
A> There is no difference between these two.
I'm coming in in the middle of this thread, but there is a very
important difference between these two.
The latter does more work because it does a string concat before
log.debug() is called. Which means if the logging level is such that
the message is suppressed, you've just wasted some time and memory.
The former can avoid all that by just not doing the string
interpolation if it's just going to throw away the log message. I use
the first form in Mailman's own logging system and I think it's a
win. I don't know which form is being argued for here, but the first
has my +1, the second a -1.
-Barry