usage of assert and -O

Matthew Russell matt at teaphoo.fsnet.co.uk
Tue Apr 8 19:27:09 EDT 2003


Hi all,

I understand that when you invoke the interpreter with the -O flag assert statments are not executed - is this 100% correct? (as i belive it to be)

and if so, shouldn't the use of assert (if not assert itself) be depricated?

I note that in unittest.py assert is not use,
we have failIf or assert_ instead - thus if you avoided using assert in your own tests you can saftly run all your unittests optimised.... 

..or can you...?

As some code in the standard library use assert,
and since most python users' applications use library modules.....

(sorry,  I cannot remmeber specificly what, but there are quite a few instances - asyncore.py is one i think)


I would be interested to know what others think about usage of assert in context with optimised python code, in particular in releation to unittesting, as this is where i think it would be useful - if not critical to have one way of doing it (i.e not useing assert or -O [ one or the other ])

Matt Russell


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030409/e92cbb23/attachment.html>


More information about the Python-list mailing list