Skip to content

Instantly share code, notes, and snippets.

@fractalbach
Created November 7, 2018 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fractalbach/f32fd94b07bf7e7011c3c5e3c8185cd3 to your computer and use it in GitHub Desktop.
Save fractalbach/f32fd94b07bf7e7011c3c5e3c8185cd3 to your computer and use it in GitHub Desktop.
simple title printer that uses ascii box chars and maintains its width
def title(s, L=70):
L = L - len(s) - 4
l1 = L // 2
l2 = L - l1
prefix = l1*'═' + '╡'
postfix = '╞' + l2*'═'
print(prefix, s, postfix)
@fractalbach
Copy link
Author

fractalbach commented Nov 7, 2018

════════════════════════╡ Samples of Output ╞═════════════════════════

Input Example:

title('Test 1')
title('Some Example')
title('Another Great Example of Stuff', 80)
title('Another Great Example of Stuff', 100)
title('Another Great Example of Stuff', 120)

Output:

══════════════════════════════╡ Test 1 ╞══════════════════════════════
═══════════════════════════╡ Some Example ╞═══════════════════════════
═══════════════════════╡ Another Great Example of Stuff ╞═══════════════════════
═════════════════════════════════╡ Another Great Example of Stuff ╞═════════════════════════════════
═══════════════════════════════════════════╡ Another Great Example of Stuff ╞═══════════════════════════════════════════

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment