#NEWLINE# def truncated( text , max_length = 100 , msg = '...' ) : #NEWLINE# #INDENT# '\n    >>> truncated("hello world!", 5)\n    \'hello...\'\n    >>> truncated("hello world!", 25)\n    \'hello world!\'\n    >>> truncated("hello world!", 5, " [truncated]")\n    \'hello [truncated]\'\n    ' #NEWLINE# if ( len ( text ) < max_length ) : #NEWLINE# #INDENT# return text #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( text [ : max_length ] + msg )