3 ms·
For what it's worth, I like that a bool is an int. It enables concise constructions such as sum(is_true(data) for data in items) to count how many items i
by 333c 7y ago
For what it's worth, I like that a bool is an int. It enables concise constructions such as
sum(is_true(data) for data in items)
to count how many items in an iterable satisfy a condition.
- woogley 7y agoJust for fun, I thought of a way to do this if booleans didn't coerce: sum(1 for data in items if is_true(data))