summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-05-04 22:03:29 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-05-04 22:03:29 +0530
commitfef62a0a13918c911b267e750a53453225fd68fe (patch)
treed3fd3286bbc8d74adab829c5e89fb9f5e005d22b
parent1d702df22b31d705a7255f9e84a7d8e516a94b18 (diff)
downloaddict-fef62a0a13918c911b267e750a53453225fd68fe.tar.gz
dict-fef62a0a13918c911b267e750a53453225fd68fe.tar.bz2
dict-fef62a0a13918c911b267e750a53453225fd68fe.zip
Made function short nameHEADmaster
-rwxr-xr-xdict.py8
1 files 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 ''}'")