Return the directory name of pathname path. This is the first element of the pair returned by passing path to the function split().
os.path.dirname(path)