In Python you can use Paths like an Object.
from pathlib import Path
p = Path("/tmp")
print(p)
print(p.exists())
print(p.is_dir())
To get the filename:
p.name
To get the suffix:
p.suffix
To get the filename without extension ( basename ):
p.stem
To get the path with an new filename/extension use:
p.with_name("test.txt")
p.with_suffix(".md")
p.with_stem("result")
Get the current working directory:
p.cwd()
Get users home directory:
p.home()
To read the file:
p.read_text()
To write into the file:
p.write_text("test")