An assert example.
This example program has an assert statement. It causes an AssertionError unless the two values add up to 110.
So If the two values add up to 110, an assertion occurs. Otherwise nothing happens.
Detail The first command line uses the "O" option. This means the assertion is optimized out of the program.
And The second command line uses no special options, so the assert is left in the program and triggered.
value = 10
value2 = 100
# Assert if this expression is not true.
(value + value2 != 110)
Traceback (most recent call last):
File "C:\programs\file.py", line 8, in <module>
assert(value + value2 != 110)