![](https://secure.gravatar.com/avatar/ab7e74f2443b81e5175638d72be65e07.jpg?s=120&d=mm&r=g)
Jan. 31, 2008
3:43 p.m.
On 31/01/2008, william ratcliff <william.ratcliff@gmail.com> wrote:
Just curious--is it safe to use the assert statement for anything beyond debugging in case someone actually runs with optimization?
If debugging is turned off, then the condition in assert is not checked. So no. More importantly, AssertionErrors *mean* that there is a bug in your program. Not that it got invlaid input, not that it's out of some resource, they mean your program has a bug. So it's okay to turn them off if you're in a hurry, because a properly-working program never signals AssertionError no matter what you feed it. And really, how hard is it to replace assert c with if not c: raise ValueError ? Anne