2 ms·
I don't know any Clojure, but I guess it's for the same reason why if lst: # do something with lst is preferred to if len(lst) > 0: # do somethin
by justwannareply 12y ago
I don't know any Clojure, but I guess it's for the same reason why
if lst:
# do something with lst
is preferred to
if len(lst) > 0:
# do something with lst
in Python. It becomes more obvious when you use descriptive names:
if customers:
# do something with customers
- tel 12y ago... but involves such an overloading of the nature of truthiness! All to match a really ad hoc syntax sugaring of English? if X ==> if there exists some X
- kyllo 12y agoIn Python, "if there exists some X" would be more like if x is not None: In Python, [] (empty list) and {} (empty dict) are == False but are not None. They exist, and their types are List and Dict rather than NoneType, but they are "falsey" because they are empty.