chainsol icon

center_for_output

chainsol | PRO | 08/28/18 04:53:09 PM UTC | 0 ⭐ | 375 👁️ | Never ⏰ | []
Python |

680 B

|

None

|

0 👍

/

0 👎

def center_for_output(label, width=78, pad_character="_", prefix="|[002|w",
                      label_format="|u{}|n|[002|w"):
    """Center and format a label for output.
 
    Args:
        label: The label to center.
        width: The width to center within. Default 78.
        pad_character: The character to pad the label with. Default "_".
        prefix: Formatting to prefix the line with.
        label_format: Formatting to wrap the label in, string format style.
    Returns:
        width wide string, with formatting characters.
    """
    centered_label = label_format.center(width + len(label_format), pad_character).format(label)
    return(prefix + centered_label)

Comments