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

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

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -