python order of evaluation with ands in if statements -
it's common put in check none or have similar error catch. need if statement depends on x:
if x == none: if x[0]>0: ... # code can safely combine if statements (for code brevity)?
if x != none , x[0]>0: ... # code or interpreter not guarantee order of evaluation , stopping after first false?
yes safe, because operators and , or short-circuits.
note:
one recommendation use
isif want check if objectnone:if x not none , x[0] > 0: # ...
Comments
Post a Comment