From c761f3736a3f2eec7b8ad226b7266c56693b7e3d Mon Sep 17 00:00:00 2001 From: Trevor John Kleinstuber <43195637+brainmagmo@users.noreply.github.com> Date: Sat, 7 Nov 2020 12:23:21 -0800 Subject: [PATCH] use with open file handling improved --- profanity/profanity.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profanity/profanity.py b/profanity/profanity.py index 6bbe18e..0bfa340 100644 --- a/profanity/profanity.py +++ b/profanity/profanity.py @@ -77,7 +77,7 @@ def load_words(wordlist=None): if not wordlist: # no wordlist was provided, load the wordlist from the local store filename = get_data('wordlist.txt') - f = open(filename) - wordlist = f.readlines() - wordlist = [w.strip() for w in wordlist if w] + with open(filename) as f + wordlist = f.readlines() + wordlist = [w.strip() for w in wordlist if w] words = wordlist