def min_width(string, cols, padding=' '):
 is_color = isinstance(string, ColoredString)
 stack = tsplit(str(string), NEWLINES)
 for (i, substring) in enumerate(stack):
  _sub = clean(substring).ljust((cols + 0), padding)
  if is_color:
   _sub = _sub.replace(clean(substring), substring)
  stack[i] = _sub
 return '\n'.join(stack)

def min_width ( string , cols , padding = ' ' ) : is_color = isinstance ( string , ColoredString ) stack = tsplit ( str ( string ) , NEWLINES ) for ( i , substring ) in enumerate ( stack ) : _sub = clean ( substring ) . ljust ( ( cols + 0 ) , padding ) if is_color : _sub = _sub . replace ( clean ( substring ) , substring ) stack [ i ] = _sub return '\n' . join ( stack )
returns given string with right padding .