code: def is_dir(path):
      
      try:
          return path.expanduser().absolute().is_dir()
      except AttributeError:
          return os.path.isdir(os.path.abspath(os.path.expanduser(str(path))))
docs: Determine if a Path or string is a directory on the file system.