I have a list of directory names:
dirnames = ["foo/bar", "foo/bar/mydir", "bar/mydir", "bar"]
I would like to (recursively) create all directories. What suffices is to recursively create the deepest directories only. In this case, it is sufficient to:
os.makedirs("foo/bar/mydir")
os.makedirs("bar/mydir")
The question: How do reduce dirnames
to have the deepest directories only?