• iAvicenna@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    4 days ago

    It is not “assume” as in a conscious “this is probably a bool I will assume so” but more like a slip of attention by someone who is more used to the bool context of not. Is “not integer” or “not list” really that commonly used that it is even comparable to its usage in bool context?

    • thebestaquaman@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      3 days ago

      Then I absolutely understand you :)

      How common it is 100 % depends on the code base and what practices are preferred. In Python code bases where I have a word in decisions, all Boolean checks should be x is True or x is False if x should be a Boolean. In that sense, if I read if x or if not x, it’s an indicator that x does not need to be a Boolean.

      In that sense, I could say that my preference is to flip it (in Python): Explicitly indicate/check for a Boolean if you expect/need a Boolean, otherwise use a “truethiness” check.