import pprint


def block_indent(text, spaces=4):
    """
    Given a multi-line string, indent every line of it by the given number of spaces.

    If `text` is not a string it is formatted using pprint.pformat.
    """
    return '\n'.join([(' ' * spaces) + l for l in pprint.pformat(text).splitlines()])