When I need to define a file system path in my script, I use os.path.join
to guarantee that the path will be consistent on different file systems:
from os import path
path_1 = path.join("home", "test", "test.txt")
I also know that there is Pathlib
library that basically does the same:
from pathlib import Path
path_2 = Path("home") / "test" / "test.txt"
What is the difference between these two ways to handle paths? Which one is better?