chainsol

center_for_output

Aug 28th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. def center_for_output(label, width=78, pad_character="_", prefix="|[002|w",
  2.                       label_format="|u{}|n|[002|w"):
  3.     """Center and format a label for output.
  4.  
  5.    Args:
  6.        label: The label to center.
  7.        width: The width to center within. Default 78.
  8.        pad_character: The character to pad the label with. Default "_".
  9.        prefix: Formatting to prefix the line with.
  10.        label_format: Formatting to wrap the label in, string format style.
  11.    Returns:
  12.        width wide string, with formatting characters.
  13.    """
  14.     centered_label = label_format.center(width + len(label_format), pad_character).format(label)
  15.     return(prefix + centered_label)
Advertisement
Add Comment
Please, Sign In to add comment