A growing collection of simple utilities functions for Python
pip install simple-toolbelt
Create the directories, include subs, if don't exist.
from simple_toolbath.path import ensure_dir
with open(ensure_dir('this/path/to/file.txt'), 'w') as f:
...