• iAvicenna@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 months ago

      I feel like that only serves the purpose up to the point that methods are not over reaching otherwise then it turns into remembering what a method does for a bunch of unrelated objects.

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months ago

      dict

      len also works on a dict.

      The point stands. If you want to check if a value is “empty,” use the check for whether it’s “empty.” In Python, that’s not. If you care about different types of empty (e.g. None vs [] vs {}), then make those checks explicit. That reads a lot better than doing an explicit check where the more common “empty” check would be correct, and it also make it a lot more obvious when you’re doing something special.