Truncate long strings.

import textwrap


textwrap.shorten("Hello  world!", width=12)
# => 'Hello world!'
textwrap.shorten("Hello  world!", width=11)
# > 'Hello [...]'
textwrap.shorten("Hello world", width=10, placeholder="...")
# => 'Hello...'

source

'{:.5}'.format('xylophone')
# => 'xylop'