reinidents a string (s) by the given number of spaces (numspaces)

def reindent(s, numspaces):
    """ reinidents a string (s) by the given number of spaces (numspaces) """
    leading_space = numspaces * ' '
    lines = [leading_space + line.strip()for line in s.splitlines()]
    return '\n'.join(lines)