(test) ? a:b
Ben Finney
ben+python at benfinney.id.au
Sat Oct 25 21:10:43 EDT 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())
Correction::
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