Hello

I 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 ?
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to