def truncate_string(string, max_len=100):
    """Shorten string s to at most n characters, appending "..." if necessary.
    """
    if string is None:
        return None
    if len(string) > max_len:
        string = string[:max_len-3] + '...'
    return string