Platform-independent file paths?

You can use os.path and its functions, which take care of OS-specific paths:

>>> import os
>>> os.path.join('app', 'subdir', 'dir', 'filename.foo')
'app/subdir/dir/filename.foo'

On Windows, it should print out with backslashes.

Leave a Comment