Returns a Path object for the directory associated with this object.

def dirpath(self):
        """Returns a Path object for the directory associated with this object."""
        if self.isfile():
            return Path(op.dirname(self._fspath))
        else:
            return Path(self)