Fix ResourceWarning: unclosed file (#681)

Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
This commit is contained in:
Mickaël Schoentgen
2019-01-08 09:59:23 +01:00
committed by Libin Yang
parent 3dc50529ca
commit 2d70e9f747
10 changed files with 104 additions and 110 deletions

View File

@ -4,7 +4,8 @@ import collections, pprint, time, os
start_time = time.time()
print('creating word list...')
path = os.path.split(os.path.realpath(__file__))
word_list = sorted(list(set([word.strip().lower() for word in open(path[0] + '/words')])))
with open(path[0] + '/words') as f:
word_list = sorted(list(set([word.strip().lower() for word in f])))
def signature(word):
return ''.join(sorted(word))