News for hackers. Stuff that matters.
Re:Python built-ins worth learning (2019) by tony-allan on Thursday March 10, 2022 @12:07AM (#30623423)
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.

There are no comments on this comment yet.