def indent ( s , spaces = 4 ) : new = re . sub ( '(\n+)' , '\\1%s' % ( ' ' * spaces ) , s ) return ( ' ' * spaces ) + new . strip ( )
adding multiple spaces between characters in a string python
Inserts spaces after each string of new lines in s and before the start of the string .
def indent(s, spaces=4):
    """
    Inserts `spaces` after each string of new lines in `s`
    and before the start of the string.
    """
    new = re.sub('(\n+)', '\\1%s' % (' ' * spaces), s)
    return (' ' * spaces) + new.strip()