• Ziglin (it/they)@lemmy.world
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    25 days ago

    Why does not without a parameter return True? I’m starting to like the fact that I haven’t touched python in a while.

    • LostXOR@fedia.io
      link
      fedilink
      arrow-up
      20
      ·
      25 days ago

      I think it’s because not() is equivalent to not(None), and since None is falsy not(None) returns True.

      • takeda@lemm.ee
        link
        fedilink
        arrow-up
        6
        arrow-down
        1
        ·
        24 days ago

        Are you sure?

        I can’t test it now, but to me it looks like () is an empty tuple. Python behavior is that for logic operations empty set equals to false. Then we apply not to get True. Not having space between not operator and parentheses makes it look like it is a function.

      • Ziglin (it/they)@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        25 days ago

        Why is literally nothing equivalent to None? Is it because None is the default value of an optional parameter? (If so why oh why is it optional)