jeudi 2 décembre 2021

How to compare paths except last part

Hi guys I want to check if my path is included in the list of paths which are allowed.

My problem is I cant just di if path1 in path_list or something cause path1 includs more then just the path it also has a file in th end of the path.

The list with allowed path are only directories

How can I check if it is part of the path_list without looking at the last part of path1?

path1 = "Folder/module/comp1/test.txt"
path_list = ["module/comp1", "module/comp2/", "module/comp3"]

Aucun commentaire:

Enregistrer un commentaire