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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With