Platform-independent file paths?

cross-platform, path, python

Solution

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.

Problem

How can I use a file inside my app folder in Python? Platform independent of course... something similar to this: ``` #!/bin/sh mypath=${0%/*} LIBDIR=$mypath/modules ```

Original source