How do I disable assertions in Python? That is - if it fails, I don't want it to throw an AssertionError, but to keep going.
+8
A:
Call Python with the -O flag:
test.py:
assert(False)
print 'Done'
Output:
C:\temp\py>C:\Python26\python.exe test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
assert(False)
AssertionError
C:\temp\py>C:\Python26\python.exe -O test.py
Done
Mark Rushakoff
2009-08-13 16:53:41
not entirely obvious from the -h command. thanks!
Claudiu
2009-08-13 16:56:04