Add method to determine if one path is a descendant of another

Issue #15 new
Rotem Yaari
created an issue

A naive approach (should probably be a bit more sophisticated to check drives etc.):

def is_parent_of(self, other):
    return not str(other.resolve().relative_to(self.resolve())).startswith("..")

Comments (1)

  1. July Tikhonov

    I guess that "there is only one obvious way to do it" approach for this problem should be some_path in other_path.parents. And it works already, reducing to iteration on other_path.parents and successive comparison.

  2. Log in to comment