0

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"]
Newone90
  • 3
  • 2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 07 '21 at 17:56

1 Answers1

0

If by "last part" you mean the filename, then you should use https://docs.python.org/3/library/os.path.html#os.path.dirname

Florin C.
  • 593
  • 4
  • 13
  • sorry I forgot to mention that in path1 there is sometime another folder before so it does not really match sometime ;/ – Newone90 Dec 02 '21 at 12:28