Best practice is to use absolute paths.
Use the __file__
path not to change directories, instead use it to calculate a base path to use to build absolute paths. In a top-level module, add:
import os.path
BASE = os.path.dirname(os.path.abspath(__file__))
and reuse BASE
to build absolute paths:
abspath = os.path.join(BASE, relpath)
Changing the working directory is rarely needed or useful.