def with_bounding_newlines(s, nleading=0, ntrailing=0, nl='\n'):
    'return s with at least # leading and # trailing newlines\n\n    this includes newlines that are separated by other whitespace\n    '
    return '{0}{1}{2}'.format((nl * (nleading - count_leading_newlines(s))), s, (nl * (ntrailing - count_trailing_newlines(s))))
return s with at least # leading and # trailing newlines

this includes newlines that are separated by other whitespace
def with_bounding_newlines(s, nleading=0, ntrailing=0, nl='\n'):
    'return s with at least # leading and # trailing newlines\n\n    this includes newlines that are separated by other whitespace\n    '
    return '{0}{1}{2}'.format((nl * (nleading - count_leading_newlines(s))), s, (nl * (ntrailing - count_trailing_newlines(s))))