def truncate(s, length):
    """Truncate a string to a specific length

    The result string is never longer than ``length``.
    Appends '..' if truncation occurred.
    """

    return (s[:length - 2] + '..') if len(s) > length else s