📜  在 python 代码示例中断言 vs 验证

📅  最后修改于: 2022-03-11 14:46:23.235000             🧑  作者: Mango

代码示例1
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"