From: Chris Withers on
Steven D'Aprano wrote:
> def strip_blank_lines(lines):
> for line in lines:
> if not line.isspace():
> yield line
>
> text = ''.join(strip_blank_lines(lines.split('\n')))

The final version I have is:

def strip_blank_lines(text):
result = []
for line in text.split('\n'):
if line and not line.isspace():
result.append(line)
return '\n'.join(result)

Any improvements would be very welcome!

Chris