def format_max_len(string_to_format, max_len=15, replace="[...]"):
    """
    Formats a string so len(format_max_length(string_to_format)) <= max_len
    If the string_to_format is longer than max_len, it replaces characters in the middle with [...]

    Example:
    >>> util.format_max_len('abcdefghijklmnopqrstuvwxyz')
    'abcde[...]vwxyz'
    """
    real_max_len = max_len-len(replace)  # needed to count the [...] in the ouput length
    if len(string_to_format) <= max_len:
        return string_to_format
    first = real_max_len // 2  # Insert the [...] in the (floored) middle
    last = real_max_len - first
    return string_to_format[0:first] + replace + string_to_format[len(string_to_format) - last:]