Is there a way to get functionality similar to mkdir -p on the shell from within Python. I am looking for a solution other than a system call. I am sure the code is less than 20 lines, and I am wondering if someone has already written it?
Other alternate way of writing mkdir -p is by using pathlib.path() function which is as follows:-
import pathlib pathlib.Path("/tmp/path/to/desired/directory").mkdir(parents=True, exist_ok=True)
The third parameter exist_ok was added in Python 3.5.