And, what is the difference between raising normal errors and assertions? Basically:
Raising Error | Assertion |
Raise ValueError('Input not in range [1, 10]') | assert 1 <= v <= 10 |
Intended for users | Intended for developers |
Happens when user action is illegal | Happens when code contains bug |
To signal to user to take a different course of action | To easily find where code starts to error |
Cannot and should not be disabled | Can be disabled during compilation, therefore should not be used in logics like data validation |