[Python-3000] Assert syntax change...

Charles Merriam charles.merriam at gmail.com
Thu Apr 24 23:13:04 CEST 2008


On Thu, Apr 24, 2008 at 2:01 PM, Guido van Rossum <guido at python.org> wrote:
> On Thu, Apr 24, 2008 at 1:51 PM, Mikhail Glushenkov
> >  Why not make ``assert`` a built-in function then?
>  Because then it can't be disabled by the compiler in -O mode.

A reasonable conclusion, but needs better reasoning.  One could
certainly do an:
    assert_stmt        ::=     "assert" (expression ["," expression])
and implement it, when there isn't a -O, as:
    __assert__(expression, message=None)  # built-in

This gives:
+ more language consistency for developer using assert().
+ over-ride assertion failure to log it correctly.
+ easier to decide not to throw exception during debugging.
- might have security concerns.

So, better reasoning?  or just ISO?


More information about the Python-3000 mailing list