I'm trying to add a directory to PATH with code like this:
PROJECT_DIR = Path(__file__).parents[2]
sys.path.append(
PROJECT_DIR / 'apps'
)
It doesn't work. If I do print sys.path I see something like this:
[..., PosixPath('/opt/project/apps')]
How should I fix this code? Is it normal to write str(PROJECT_DIR / 'apps')?
str?str: The string representation of a path is the raw filesystem path itself (in native form, e.g. with backslashes under Windows), which you can pass to any function taking a file path as a string.