Get Absolute Path for Parent Directory

PHOTO EMBED

Fri Mar 19 2021 15:34:13 GMT+0000 (Coordinated Universal Time)

Saved by @FlorianC #python

import os

def parent_directory():

  # Create a relative path to the parent 
  # of the current working directory 

  relative_parent = os.path.join(os.getcwd(),'..')

  # Return the absolute path of the parent directory

  return os.path.abspath(relative_parent)

print(parent_directory())
content_copyCOPY