def tstr(s, maxLength=80, ellipsis="..."):
    """
    Truncates the string `s` and adds ellipsis such that the returned string
    has at most `maxLength` characters, including the ellipsis.

    >>> tstr('The quick brown fox jumps over the lazy dog', 40)
    'The quick brown fox jumps over the la...'
    """

    if len(s) > maxLength:
        return s[:max(0, maxLength - len(ellipsis))] + ellipsis
    else:
        return s