(test) ? a:b

Ben Finney ben+python at benfinney.id.au
Sun Oct 26 02:10:43 CET 2014

Ben Finney <ben+python at benfinney.id.au> writes:

> This is short and clear and needs no leaking of the underlying bool
> implementation::
>     len(True for line in lines if line.strip())


    len([True for line in lines if line.strip()])

 \     “Our task must be to free ourselves from our prison by widening |
  `\    our circle of compassion to embrace all humanity and the whole |
_o__)                       of nature in its beauty.” —Albert Einstein |
Ben Finney

More information about the Python-list mailing list