• JasonDJ@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    if isinstance(mylist, list) and not mylist

    Problem solved.

    Or if not mylist # check if list is empty

    • gravitas_deficiency@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 months ago

      You’re checking if mylist is falsey. Sometimes that’s the same as checking if it’s empty, if it’s actually a list, but that’s not guaranteed.

      • JasonDJ@lemmy.zip
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 months ago

        Doesn’t Python treat all empty iterables as false tho? This isn’t unique to python, is it? (though I’m not a programmer…just a dude who writes scripts every now and then)