From fef62a0a13918c911b267e750a53453225fd68fe Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Sat, 4 May 2024 22:03:29 +0530 Subject: Made function short name --- dict.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dict.py b/dict.py index aca3fbf..31676d6 100755 --- a/dict.py +++ b/dict.py @@ -8,7 +8,7 @@ import sys # Import for potential error handling # Customizable word list path WORD_LIST_PATH = "~/.local/share/vocab/words.txt" -def get_random_word_from_urban_dictionary(): +def fetch_dict(): """Retrieves a random word and definition from Urban Dictionary API.""" url = "http://api.urbandictionary.com/v0/random" @@ -24,7 +24,7 @@ def get_random_word_from_urban_dictionary(): except requests.exceptions.RequestException: return None, None -def get_random_word_from_local_file(): +def local_dict(): """Retrieves a random word from the local word list.""" try: # Expand '~' for the home directory in the path @@ -40,10 +40,10 @@ def get_random_word_from_local_file(): return None if __name__ == "__main__": - word, definition = get_random_word_from_urban_dictionary() + word, definition = fetch_dict() if not word: # Check if word retrieval failed - word = get_random_word_from_local_file() + word = local_dict() if word: os.system(f"cowsay '{word} -> {definition if definition else ''}'") -- cgit v1.2.3-59-g8ed1b