> On 7 May 2018, at 18:52, Guido van Rossum <gu...@python.org> wrote: > > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka <storch...@gmail.com > <mailto:storch...@gmail.com>> wrote: > I just don't understand why you need a new keyword for writing runtime checks. > > 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 > > runtime_assert(<expr>) > > expands to > > if <controlling flag> and (<expr>): > raise AssertionError > > In Lisp this would be easy. :-)
This idea requires the same sort of machinery in python that I was hoping for to implement the short circuit logging. My logging example would be log( control_flag, msg_expr ) expanding to: if <control_flag>: log_function( <msg_expr> ) Barry
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/