On 06/04/2016 14:07, ast wrote:
HelloI would like to know if it is advised or not to test a function's parameters before running it, e.g for functions stored on a public library ? Example: def to_base(nber, base=16, use_af=True, sep=''): assert isinstance(nber, int) and nber >= 0 assert isinstance(base, int) and base >= 2 assert isinstance(use_af, bool) assert isinstance(sep, str) and len(sep) == 1 tbc With these tests, you are sure that the function to_base is well used. But it slows down the program. Without, python interpreter may crash later in the function or worse provide a meaningless result. What library designers do ?
Please see http://ftp.dev411.com/t/python/python-list/13bhcknhan/when-to-use-assert
-- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
