Get parent of current directory from Python script
Using os.path To get the parent directory of the directory containing the script (regardless of the current working directory), you’ll need to use __file__. Inside the script use os.path.abspath(__file__) to obtain the absolute path of the script, and call os.path.dirname twice: from os.path import dirname, abspath d = dirname(dirname(abspath(__file__))) # /home/kristina/desire-directory Basically, you can walk … Read more