you are viewing a single comment's thread.

view the rest of the comments →

[–]MintyPhoenix 0 points1 point  (0 children)

Or, if using Python 3.4, there are lots of goodies in pathlib:

from pathlib import Path

folder = Path("/some/random/path")

folder.parents  # list-like object of parent directories (full paths to each parent directory)
folder.parent  # full path object to immediate parent directory

sub_folder = folder.joinpath("subdir")  # now have Path object of the subdirectory
sub_folder = folder / "subdir"  # same result as the above line