Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

assert vs validate in python

from types import IntType, StringType
def some_func(int_arg, str_arg, other_arg):
    assert type(int_arg) == IntType, "id is not an integer: %r" % int_arg
    assert type(str_arg) == StringType or not str_arg
    assert other_arg in (VALUE1, VALUE2, VALUE3), "other arg must be VALUE1, VALUE2, or VALUE3"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #assert #validate #python
ADD COMMENT
Topic
Name
5+3 =