nagaram/scrabble.py
def word_list(sowpods=False, start="", end=""):
    """Opens the word list file.

    Args:
        sowpods: a boolean to declare using the sowpods list or TWL (default)
        start: a string of starting characters to find anagrams based on
        end: a string of ending characters to find anagrams based on

    Yeilds:
        a word at a time out of 178691 words for TWL, 267751 for sowpods. Much
        less if either start or end are used (filtering is applied here)
    """

    location = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        "wordlists",
    )

    if sowpods:
        filename = "sowpods.txt"
    else:
        filename = "twl.txt"

    filepath = os.path.join(location, filename)

    with open(filepath) as wordfile:
        for word in wordfile.readlines():
            word = word.strip()
            if start and end and word.startswith(start) and word.endswith(end):
                yield word
            elif start and word.startswith(start) and not end:
                yield word
            elif end and word.endswith(end) and not start:
                yield word
            elif not start and not end:
                yield word
def word_list(sowpods=False, start="", end=""):
    """Opens the word list file.

    Args:
        sowpods: a boolean to declare using the sowpods list or TWL (default)
        start: a string of starting characters to find anagrams based on
        end: a string of ending characters to find anagrams based on

    Yeilds:
        a word at a time out of 178691 words for TWL, 267751 for sowpods. Much
        less if either start or end are used (filtering is applied here)
    """

    location = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        "wordlists",
    )

    if sowpods:
        filename = "sowpods.txt"
    else:
        filename = "twl.txt"

    filepath = os.path.join(location, filename)

    with open(filepath) as wordfile:
        for word in wordfile.readlines():
            word = word.strip()
            if start and end and word.startswith(start) and word.endswith(end):
                yield word
            elif start and word.startswith(start) and not end:
                yield word
            elif end and word.endswith(end) and not start:
                yield word
            elif not start and not end:
                yield word
Opens the word list file.

    Args:
        sowpods: a boolean to declare using the sowpods list or TWL (default)
        start: a string of starting characters to find anagrams based on
        end: a string of ending characters to find anagrams based on

    Yeilds:
        a word at a time out of 178691 words for TWL, 267751 for sowpods. Much
        less if either start or end are used (filtering is applied here)