def extract_words ( lines ) : for line in lines : for word in re . findall ( r"\w+" , line ) : yield word
python iterate through words in line of text file
Extract from the given iterable of lines the list of words .
def extract_words(lines):
    """
    Extract from the given iterable of lines the list of words.

    :param lines: an iterable of lines;
    :return: a generator of words of lines.
    """
    for line in lines:
        for word in re.findall(r"\w+", line):
            yield word