import json


def as_block_string(txt):
    """Return a string formatted as a python block comment string, like the one
    you're currently reading. Special characters are escaped if necessary.
    """

    lines = []
    for line in txt.split('\n'):
        line_ = json.dumps(line, ensure_ascii=False)
        line_ = line_[1:-1].rstrip()  # drop double quotes
        lines.append(line_)

    return '"""\n%s\n"""' % '\n'.join(lines)