<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Interessting alternatives, but they do not quite come on as flexible/usefull enough…</div><div><br></div>Often debug statements have a lot of text and variables, like:<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>log.debug( "The value of X, Y, Z is now: %d %s %d" % ( x, lookup(y), factorial(2**15))</div><div><br></div><div>It would be nice if args in log.debug() was only evaluated if debug was on. But I don't think this is possible with the current Python evaluation rules.</div><div><br></div><div>But if debug() was indeed NOP'able, maybe it could be done ?</div><div><br></div><div>/Rene</div><div><br></div><div><div><div>On Dec 25, 2012, at 10:35 AM, Jakob Bowyer <<a href="mailto:jkbbwr@gmail.com">jkbbwr@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Why not pass the function/method, args, kwargs to log.debug and let log.debug decide if it should execute or not,<div style="">e.g.</div><div style=""><br></div><div style="">log.debug(factorial, 2**15)</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Dec 25, 2012 at 7:40 AM, Jasper St. Pierre <span dir="ltr"><<a href="mailto:jstpierre@mecheye.net" target="_blank">jstpierre@mecheye.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>if __debug__:<br></div>    log(factorial(2**15))<br><br></div><div>Running python with -O will squash this statement. To have something inline, you could also abuse assert statements to do the job.<br>

<br></div><div>def debug_log(x):<br></div><div>    log(x)<br></div><div>    return True<br></div><div><br></div><div>assert debug_log(factorial(2**15))<br><br></div><div>In optimized builds, the statement will be removed entirely.<br>

<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Tue, Dec 25, 2012 at 1:28 AM, anatoly techtonik <span dir="ltr"><<a href="mailto:techtonik@gmail.com" target="_blank">techtonik@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">For the logging module it will be extremely useful if Python included a way to disactivate processing certain blocks to avoid making sacrifices between extensive logging harness and performance. For example, instead of writing:<div>



<br></div><div>if log.DEBUG==True:</div><div>  log(factorial(2**15))<br></div><div><br></div><div>It should be possible to just write:</div><div><div>  log(factorial(2**15))<br></div><div><br>

</div></div><div><div>if if log() is an instance of some Nopable class, the statement in log's braces is not executed.</div><span><font color="#888888">-- <br><div>anatoly t.</div>
</font></span></div></div>
<br></div></div><div class="im">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br></div></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br>  Jasper<br>
</font></span></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>Python-ideas mailing list<br><a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>http://mail.python.org/mailman/listinfo/python-ideas<br></blockquote></div><br></div></body></html>