I wonder if there any more pythonic way to write this function:
def parse(filename):
with open(filename, 'r', encoding='koi8-r') as f:
for log_line in f:
for s in services:
if ' ' + s + ' ' in log_line:
print(s)
services.remove(s)
Use sets:
This presumes the
servicesglobal is a list. Note that it’d be much better to pass in services then return the result: