I'm just trying to understand the "keys =" line of code in the following script. This script was pulled in an answer linked below. I would just comment on that section but I don't have enough points to comment.
Search Multiple Strings (from File) in a file and print the line
I am having a hard time finding documentation on what "key for key" is. From what I found, it is part of the dictionary but any help in understanding that part would be greatly appreciated. Thanks!
keyfile = "keys.txt"
testfile = "test.txt"
keys = [key for key in (line.strip() for line in open(keyfile)) if key]
with open(testfile) as f:
for line in f:
for key in keys:
if key in line:
print(line, end='')
break