Any clean way to do path calculation rather than string split in Python?
working_dir = "/a/b/c/d/e/f/g", given_dir = "d/e/f/g"
How do I get parent path "/a/b/c"
?
Any clean way to do path calculation rather than string split in Python?
working_dir = "/a/b/c/d/e/f/g", given_dir = "d/e/f/g"
How do I get parent path "/a/b/c"
?
The top directory you can get with:
os.path.split(working_dir)[0]
So you just do that the number of times you need...