src.ch02 package¶
Submodules¶
src.ch02.c1_recursive_palindrome module¶
Recursively determine if a word is a palindrome.
src.ch02.p1_cleanup_dictionary module¶
Cleanup word dictionary.
Various functions for cleaning up a word dictionary.
-
src.ch02.p1_cleanup_dictionary.
APPROVED_WORDS
¶ Words that should always appear in a word dictionary.
- Type
-
src.ch02.p1_cleanup_dictionary.
cleanup_dict
(filepath: str) → list[source]¶ Wrap read_from_file and cleanup_list.
Passes given filepath through
read_from_file()
to get a list of words, thencleanup_list()
to remove single letter words.- Parameters
filepath (str) – String with path to word dictionary file.
- Returns
List with words as elements excluding single letter words.
-
src.ch02.p1_cleanup_dictionary.
cleanup_list
(word_list: list) → list[source]¶ Cleanup word list.
Remove single letter words from a
list
of words.- Parameters
word_list (list) – List with words as elements.
- Returns
List with words as elements excluding single letter words.
- Raises
IndexError – If word_list is empty.
-
src.ch02.p1_cleanup_dictionary.
cleanup_list_more
(word_list: list) → list[source]¶ Cleanup word list even more.
First, remove words with apostrophes, double letter words, duplicates, and words with letters not in
string.ascii_lowercase
from alist
of words. Then, addAPPROVED_WORDS
back into list. Finally, sort list.- Parameters
word_list (list) – List with words as elements.
- Returns
Sorted list with words as elements excluding cleaned words and
APPROVED_WORDS
added.- Raises
IndexError – If word_list is empty.
Module contents¶
Chapter 2.
-
src.ch02.
DICTIONARY_FILE_PATH
¶ String with path to Ubuntu 18.04.2’s American English dictionary file.
- Type
-
src.ch02.
CLEANUP_LIST_ERROR
¶ String with
IndexError
for Cleanup Dictionarycleanup_list()
.- Type
-
src.ch02.
RECURSIVE_ISPALINDROME_ERROR
¶ String with
TypeError
for Recursive Palindromerecursive_ispalindrome()
.- Type