News for hackers. Stuff that matters.
Re:Hidden features of Python by bobbyi on Wednesday July 14, 2010 @12:25AM (#1513595)
It's useful because it allows you to add together booleans to get a count of how many are true.

You can check if two out of three are true with

(bool1 + bool2 + bool3) >= 2

You can do

count_negatives = sum(number < 0 for number in numbers)

There are no comments on this comment yet.