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

The very first example is stupid. What sane language would assume a non-empty string should be converted to a False boolean?



isn't it doing the opposite? str(False) is the string "False", which bool() casts to True because it is a non-empty string; Non-empty strings are cast to True booleans.

This is much faster than checking if the string has some semantic meaning first, which would have to be localized.


That's exactly what the grandparent is saying




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

Search: