Last active
February 20, 2017 20:31
-
-
Save NotTheEconomist/a3d3e3798e652259480cbeaeb94dd6b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d = {} | |
with open("dictfile.txt") as f: | |
d.update([map(str.strip, line.split("=")) for line in f]) | |
# alternatively: | |
# for line in f: | |
# k, v = line.split('=') | |
# d[k.strip()] = v.strip() | |
with open("wordfile.txt") as f: | |
for line in f: | |
words = filter(None, [str(d.get(word, '')) for word in line]) # the cast to str is actually unnecessary here | |
# alternatively: | |
# words = [] | |
# for word in line: | |
# words.append(str(d.get(word, ''))) | |
# words = filter(None, words) | |
print(", ".join(words)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment