def genSubstr(string, n):
    """
    Generate all substrings of max length n for string
    """
    length = len(string)
    res = [string[i: j] for i in range(0, length)
        for j in range(i + 1, min(i + n + 1, length + 1))]
    return res

    Generate all substrings of max length n for string
    
harvesttext/algorithms/word_discoverer.py