code: def get_parent_directory(path):
      
      if not os.path.isdir(path): path = os.path.dirname(path)
      return os.path.abspath(os.path.join(path, os.path.pardir))
docs: Like os.path.dirname except it returns the absolute name of the parent
      of the dirname directory.  No symbolic link expansion (os.path.realpath)
      or user expansion (os.path.expanduser) is done.