assert vs validate in python

Solutions on MaxInterview for assert vs validate in python by the best coders in the world

showing results for - "assert vs validate in python"
Marta
08 Oct 2020
1from types import IntType, StringType
2def some_func(int_arg, str_arg, other_arg):
3    assert type(int_arg) == IntType, "id is not an integer: %r" % int_arg
4    assert type(str_arg) == StringType or not str_arg
5    assert other_arg in (VALUE1, VALUE2, VALUE3), "other arg must be VALUE1, VALUE2, or VALUE3"