Rather than patch your code, I think you should see a better approach.

from textwrap import dedent # removes common whitespace prefix

lines = []

def add_header(ss):
    "Add header to sequence of string lines"
    ss.append(dedent("""\ # No initial blank line
    my multi-line
    string here
    """))

def add_more(ss):
    "Add more to sequence of string lines"
    ss.append(dedent(""" # Start with blank line
    another
    multi-line
    string here
    """))

add_header(lines)
add_more(lines)

print(''.join(lines)) # prints
--------------------------------
my multi-line
string here

another
multi-line
string here

--------------------------------

PS. Only use 'gen' for naming generator functions when you get to them.
--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to