Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Too many falsy values. 0, Nan, '' (empty string), false, null, undefined are all false.

I disagree with that, actually. I like that many Python objects can be used in a boolean context and behave sensibly, and that this behavior is accessible to user-defined-types.

On this point, Javascript annoys me because on some things it works as Python (empty string) whereas in others it does not (empty array).

> for ... in operator mixes inherited functions with the desired data members (it does deep reflection).

It does not do any reflection, really. It just iterates on all enumerable properties of the object, inherited or not.



It's nice how Python has "is False". In JavaScript it's "=== false". The python version reads a lot better IMHO.


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: