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