Paul Rudin <paul.nos...@rudin.co.uk> writes:

> Falcolas <garri...@gmail.com> 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

Reply via email to