heading#
- heading(string='', *args, color='cyan', divider='—', spaces=2, spacesafter=1, minlength=10, maxlength=200, sep=' ', doprint=None, output=False, **kwargs)[source]#
Create a colorful heading. If just supplied with a string (or list of inputs like print()), create blue text with horizontal lines above and below and 3 spaces above. You can customize the color, the divider character, how many spaces appear before the heading, and the minimum length of the divider (otherwise will expand to match the length of the string, up to a maximum length).
- Parameters:
string (str) – the string to print as the heading (or object to convert to a string)
args (list) – additional strings to print
color (str) – color to use for the heading (default cyan)
divider (str) – symbol to use for the divider (default ‘—‘)
spaces (int) – number of spaces to put before the heading (default 2)
spacesafter (int) – number of spaces to put after the heading (default 1)
minlength (int) – minimum length of the divider (default 10)
maxlength (int) – maximum length of the divider (default 200)
sep (str) – if multiple arguments are supplied, use this separator to join them
doprint (bool) – whether to print the string (default true if no output)
output (bool) – whether to return the string as output (else, print)
kwargs (dict) – passed to
sc.colorize()
- Returns:
Formatted string if
output=True
- Examples::
sc.heading(‘This is a heading’) sc.heading(string=’This is also a heading’, color=’red’, divider=’*’, spaces=0, minlength=50)
New in version 1.3.1.: “spacesafter”