The best Python feature you cannot use
Instead of having to limit sanity checks to the boundaries of the program, we could re-use those as function contracts using the
assert
keyword. Indeed, settingPYTHONOPTIMIZE
removes allassert
, making the check useful in dev, and free in production.Unfortunately, the community doesn't know about the feature, and use
assert
for things that should never be removed, so using the flag would likely introduce bugs into your program.