list comprehension problem

Paul Rudin paul.nospam at rudin.co.uk
Tue Nov 3 08:10:27 CET 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