4 ms·
It's nice how Python has "is False". In JavaScript it's "=== false". The python version reads a lot better IMHO.
by benatkin 15y ago
It's nice how Python has "is False". In JavaScript it's "=== false". The python version reads a lot better IMHO.
- steve-howard 15y agoIt's more idiomatic in python to just test for truthiness (i.e. "not x" rather than "x is False"). There aren't a lot of cases where you'd want False to be false but not None, 0, or an empty container.
- masklinn 15y agoIt is quite common for `None` though.
- benatkin 15y agoTrue. If I'm expecting a bool and just writing is True to program defensively, what I should really be doing is assert(type(x) is bool) if I want to make sure I was given a boolean value or x = bool(x) if I want to make sure I'm outputting bool.