Files
pycmx/pycmx/util.py
2018-11-29 22:04:53 -08:00

18 lines
372 B
Python

# pycmx
# (c) 2018 Jamie Hardt
# Utility functions
def collimate(a_string, column_widths):
'Splits a string into substrings that are column_widths length.'
if len(column_widths) == 0:
return []
width = column_widths[0]
element = a_string[:width]
rest = a_string[width:]
return [element] + collimate(rest, column_widths[1:])