Nov-02-2016, 09:48 PM
Hello,
I'm splitting the path from the filename and I would like to compare the file name against a list of elements in a list and if there's an exact match to any of the elements in the list, flip a variable value to true. This is what I have below, and it seems to be working, but I want to run this by those with more experience to see if I missed anything.
I'm splitting the path from the filename and I would like to compare the file name against a list of elements in a list and if there's an exact match to any of the elements in the list, flip a variable value to true. This is what I have below, and it seems to be working, but I want to run this by those with more experience to see if I missed anything.
file_lst = ['.file.edn', '.config.json', 'TEMPLATE', 'README.md'] contains_file_in_file_lst = False path, fname = os.path.split(file_information.filename) if any(fname in filename for filename in file_lst): contains_file_in_file_lst = True