Have a look at Python's Format Specification Mini-Language and printf-style String Formatting.
EXAMPLE:
>>> '{:<20} {}'.format('## execute', 'Execute an IRC command')
'## execute Execute an IRC command'
Note that format()
was introduced in Python 3.0 and backported to Python 2.6, so if you are using an older version, the same result can be achieved by:
>>> '%-20s %s' % ('## execute', 'Execute an IRC command')
'## execute Execute an IRC command'
It's necessary to split the strings in a sensible manner beforehand.
EXAMPLE:
>>> '{:<20} {}'.format(*'{0} <COMMAND>: Help for <command>'.split(': '))
'{0} <COMMAND> Help for <command>'
>>> '%-20s %s' % tuple('{0} <COMMAND>: Help for <command>'.split(': '))
'{0} <COMMAND> Help for <command>