def comment_out(text, comment="#"):
    """
    Comment out some text, using the specified comment character(s) at the
    start of each line.
    """
    text = text.strip()

    result = ""
    for line in text.split("\n"):
        if line: result += comment+" "+line+"\n"
        else: result += comment+"\n"

    return result.strip()