<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 7 May 2018, at 18:52, Guido van Rossum <<a href="mailto:guido@python.org" class="">guido@python.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka <span dir="ltr" class=""><<a href="mailto:storchaka@gmail.com" target="_blank" class="">storchaka@gmail.com</a>></span> wrote:<span class=""></span><br class=""><span class=""></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I just don't understand why you need a new keyword for writing runtime checks.<br class=""></blockquote></div><br class=""></div><div class="gmail_extra">Oh, that's pretty clear. The OP wants to be able to turn these checks off with some flag he can set/clear at runtime, and when it's off he doesn't want to incur the overhead of evaluating the check. The assert statement has the latter property, but you have to use -O to turn it off. He basically wants a macro so that<br class=""><br class=""></div><div class="gmail_extra">  runtime_assert(<expr>)<br class=""><br class=""></div><div class="gmail_extra">expands to<br class=""><br class=""></div><div class="gmail_extra">  if <controlling flag> and (<expr>):<br class="">      raise AssertionError<br clear="all" class=""></div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">In Lisp this would be easy. :-)<br class=""></div></div></div></blockquote><div><br class=""></div><div><div>This idea requires the same sort of machinery in python that I was hoping for to implement the short circuit logging.</div><div><br class=""></div><div>My logging example would be</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">  </span>log( control_flag, msg_expr )</div><div><br class=""></div><div>expanding to:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>if <control_flag>:</div><div><span class="Apple-tab-span" style="white-space:pre">             </span>log_function( <msg_expr> )</div><div><br class=""></div><div>Barry</div><div><br class=""></div></div></div></body></html>