list comprehension problem

Paul Rudin paul.nospam at rudin.co.uk
Tue Nov 3 02:10:27 EST 2009


Falcolas <garrickp at 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. I'd probably write:

filter(None, (s.strip() for s in hosts))



More information about the Python-list mailing list