you are viewing a single comment's thread
view the rest of the comments
[+] 23 points 1 year ago* (last edited 1 year ago) (11 children)
  • [–] 6 points 1 year ago (1 child)

    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.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 5 points 1 year ago (5 children)

    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)

  • source
  • parent
  • hideshow 5 child comments
  • [–] 5 points 1 year ago* (4 children)

    Because nothing isn't something, and something is true. It's base Boolean logic where everything is either true or false. Null/nothing is false.

    It's a weird way to think about conditionals, but it makes sense when you use them in real examples. In my case, I use them like this when I need to make sure that a variable has a value. So I can do something like

    If(variable){do things with the variable}else{do stuff when the variable doesn't exist}

  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 1 year ago (3 children)

    I understand that, it makes sense. But why does it not throw an error? The parameter is missing after all.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 2 points 1 year ago (1 child)

    Actually the explanation is wrong.

    not()
    

    is actually

    not ()
    

    not is a keyword not a function.

    Boolean of empty tuple is False and then not negates it.

    I explained it better here:

    https://lemm.ee/post/61594443/19783421

  • source
  • parent
  • hideshow 1 child comment