Paul Rudin <[email protected]> writes:
> Falcolas <[email protected]> writes:
>
> > [s.strip() for s in hosts if s.strip()]
>
> There's something in me that rebels against seeing the same call
> twice.
Agreed. I'd probably use:
>>> lines = ["foo", " ", " bar ", "", "baz"]
>>> [s for s in (s.strip() for s in lines) if s]
['foo', 'bar', 'baz']
--
\ “[I]t is impossible for anyone to begin to learn that which he |
`\ thinks he already knows.” —Epictetus, _Discourses_ |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list