Suppose I have the following paths:
/tmp/a
/tmp/abc
/tmp/abc/d/my_file.py
How can I check if a /tmp/abc/d/my_file.pysubpath is /tmp/abc? I tried:
file_path.startswith(dir_path)
But it returns Truefor the directory /tmp/a, my_file.pynot in it.
source
share