3 ms·
If you use the technique more generally, you need to watch out for the first case: bool(0) -> False bool(1) -> True bool(str('0')) -> True bool(str('')
by tony-allan 5y ago
If you use the technique more generally, you need to watch out for the first case:
bool(0) -> False
bool(1) -> True
bool(str('0')) -> True
bool(str('')) -> False
bool(None) -> False
If you are checking that a variable is set bool(some_var) doesn't work for 0.