def shrink(line, bound=50, rep='[...]'):
    """Shrinks a string, adding an ellipsis to the middle"""
    l = len(line)
    if l < bound:
        return line
    if bound <= len(rep):
        return rep
    k = bound - len(rep)
    return line[0:k / 2] + rep + line[-k / 2:]