line_gen = (m.group(1) for m in re.finditer('(.*?)(\n|$)', src))
"""
""".join(s for s in line_gen if not s.startswith('#'))
How do I split a string and rejoin it without creating an intermediate list in Python?