simultaneous assignment

John Salerno johnjsal at
Tue May 2 21:11:36 CEST 2006

Grant Edwards wrote:

> Python knows how to count.  :)
> def countFalse(seq):
>     return len([v for v in seq if not v])
> def countTrue(seq):
>     return len([v for v in seq if v])
> def truth_test(seq):
>     return countTrue(seq) == 1

Gosh, so much to learn! Of course, I already know all about list 
comprehensions, but now I just need to learn to *use* them! :)

More information about the Python-list mailing list