• Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    6
    ·
    6 hours ago

    You always want explicitness when programming. Not everyone reading your code will be deep into Python and relying on falsiness makes it harder to understand.

    • fruitcantfly@programming.dev
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      3 hours ago

      Containers being “truthy” is quite basic Python and you will find this idiom used in nearly every Python code base in my experience

      • Ephera@lemmy.ml
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        2 hours ago

        Yeah, I’m talking less deep than that. Plenty programming beginners will be reading Python code. And personally, I’m a fulltime software engineer, but just don’t do much Python, so while I had it in the back of my mind that Python does truthiness, I would have still thought that var must be a boolean, because it’s being negated. Obviously, a different variable name might’ve given me more of a clue, but it really doesn’t reduce mental complexity when I can’t be sure what’s actually in a variable.

        • fruitcantfly@programming.dev
          link
          fedilink
          arrow-up
          1
          arrow-down
          1
          ·
          edit-2
          2 hours ago

          But if those beginners want to stop being beginners, then they must learn the basics of the language. It makes no more sense to demand that everyone who programs in Python caters to beginners, than it makes to demand that everyone writing in English write at a 3rd grade reading level for the sake of English language learners

          • Ephera@lemmy.ml
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 hour ago

            Yeah, my stance for both of those is the same: If the complexity aids you in communicating better, then use it. But if you’re using big words where small words would do, then you’re doing a disservice to your readers.