Ticket #3589 (new enhancement)
Convenience method for verifying if one path is ancestor of another
| Reported by: | jml | Owned by: | jml |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Keywords: | |
| Cc: | Branch: | ||
| Author: | Launchpad Bug: |
Description
I recently found myself wanting to check whether one path is the ancestor of another. It's a pain in the neck using os.path, so I checked out FilePath too see if it offered any help.
FilePath.segmentsFrom is very close to what I want. In fact, something like the following would be perfect:
def isParent(self, ancestor): try: self.segmentsFrom(ancestor) except ValueError: return False else: return True
Incidentally, why ValueError?
Change History
Note: See
TracTickets for help on using
tickets.
