Pathlib

from pathlib import Path
assert Path(<some_file>).is_file()

To get the Path of the current file, or a parent:

Path('.').resolve()
Path('.').resolve().parent
from pathlib import Path
a = Path('/one/two/three.jpg')
a.parent, a.name, a.stem
(PosixPath('/one/two'), 'three.jpg', 'three')

Platform

import platform
if 'macOS' in platform.platform():
    print('This is Mac')
This is Mac
<some_path>.mkdir(parents=True, exist_ok=True)