Assertions

An assertion is a statement that a true–false expression is expected to always be true at that point in the code.The assert statement verifies that an expression is true or it raises an AssertionError. Unlike conditions, which are always executed, assert statements may be disabled when optimization is requested (using command line option -O).

def function(integer):
    assert type(integer) is int
    assert integer >= 0
    ...

results matching ""

    No results matching ""