from textwrap import TextWrapper
w = TextWrapper(16, break_long_words=True)
w.wrap('this_is_a_really_long_word')
w = TextWrapper(16, break_long_words=False)
w.wrap('this_is_a_really_long_word')
Python - split sentence after words but with maximum of n characters in result