Hacker News new | past | comments | ask | show | jobs | submit login

It'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.



True. 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.


It is quite common for `None` though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: