13.2. File Path Absolute

  • Python works with both relative and absolute path

  • Path separator \ (backslash) is used on Windows

  • Path separator / (slash) is used on *nix operating systems: Linux, macOS, BSD and other POSIX compliant OSes (excluding older versions of Windows)

  • In newer Windows versions both \ and / works the same

13.2.1. Absolute Path

  • Absolute path on Windows starts with drive letter

  • Absolute path on *nix starts with root / dir

  • Absolute path include all entries in the directories hierarchy

Path on Linux:

>>> FILE = r'/home/mwatney/myfile.txt'

Path on macOS:

>>> FILE = r'/Users/mwatney/myfile.txt'

Path on Windows:

>>> FILE = 'C:\\Users\\mwatney\\myfile.txt'