def _left_pad(text, indent=" "):
"""Maybe I can find a package in pypi for this?"""
return "\n".join(indent + line for line in text.split('\n'))
You can use the textwrap module from the Python standard library for this: textwrap.indent('hello\nthis\n is a demo', ' ')
# ' hello\n this\n is a demo'