0

The title honestly says it all: Why does not None return True. I have seen that bool(None) apparently returns False. Is there a good explanation as to why these two events occur this way ?

Edit: I guess what I'm really asking is what led to python implementing None as being a falsy type ?

A.D
  • 427
  • 1
  • 4
  • 12
  • 2
    What else should it return? – Barmar Nov 08 '19 at 17:00
  • I guess in that case you could ask: why is None falsey ? Is there a reason behind this implementation ? – A.D Nov 08 '19 at 17:02
  • @Barmar I don't know, I was just not expecting not None to return a boolean... – A.D Nov 08 '19 at 17:02
  • 1
    You could also try `not 0`, `not []`, and `not ''` -- all are falsy values, so they will result in `True`. And you could try `not 1`, `not [0]`, and `not '0'`, which will all result in `False`. – Fred Larson Nov 08 '19 at 17:02
  • `not ` always returns a boolean. Why should it be different for `None`? – Barmar Nov 08 '19 at 17:03
  • @FredLarson Alright, that does make sense, I guess now I'm just womdering how the choice determining what was Falsy or not was made – A.D Nov 08 '19 at 17:06
  • 1
    Basically, anything zero or empty will be falsy. The linked dupe has more detailed info. – Fred Larson Nov 08 '19 at 17:11

1 Answers1

1

Because negating any falsy value value will result in True.

ruohola
  • 21,987
  • 6
  • 62
  • 97