human
I wrote the below code

    from PyQt5.Qt import QFontMetrics, QApplication
    fm = (QApplication.fontMetrics() if (font is None) else (font if isinstance(font, QFontMetrics) else QFontMetrics(font)))
    delta = 4
    ellipsis = u'\u2026'
    def remove_middle(x):
        mid = (len(x) // 2)
        return ((x[:max(0, (mid - (delta // 2)))] + ellipsis) + x[(mid + (delta // 2)):])
    chomp = {'middle': remove_middle, 'left': (lambda x: (ellipsis + x[delta:])), 'right': (lambda x: (x[:(- delta)] + ellipsis))}[pos]
    while ((len(text) > delta) and (fm.width(text) > width)):
        text = chomp(text)
    return unicode(text)

What's a good function header?
 ... Here's a good function header?
assistant
#Here's a good function header.

def elided_text(text, font=None, width=300, pos='middle'):