python - Does precondition assertion testing replace assumptions in a function specification or vice versa? -


i'm confused when use assertion testing in python functions. if specify assumptions regarding input arguments function, should assume correct input being fed function or should use assertions check conditions on input args enumerated in specification?

if you're writing "public" function, believe pythonic way check arguments (using if, not assert), and, if they're invalid, raise exception type , info / message designed provide info possible.

if you're writing function designed internal use, using assert check arguments seems idea me.


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -