How to find where data files are installed for my Python program (was: Function for the path of the script?)

rurpy at yahoo.com rurpy at yahoo.com
Sun Oct 27 01:18:33 EDT 2013


On 10/26/2013 10:28 PM, Ben Finney wrote:
> Chris Angelico <rosuav at gmail.com> writes:
> 
>> It's very common to want to know what directory you're in - it's a
>> good way to find data files.
> 
> That's a naive way to do it (though it's often good enough, for a
> program only used on one system).
> 
> For programs intending to be used across many systems, the data files
> often shouldn't be placed in the same directory as the program.
> 
> On systems conforming to the Filesystem Hierarchy Standard, it's
> forbidden: programs go in a platform-specific location
> <URL:http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#USRLIBLIBRARIESFORPROGRAMMINGANDPA>,
> while platform-independent data files go in a separate location
> <URL:http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#USRSHAREARCHITECTUREINDEPENDENTDATA>.

What about Python applications installed in /opt?
On my systems, unless a third party app is packaged and
distributed by the OS package manager, it goes in /opt
and AFAIK, it is blessed practice to keep all the app
files in the same subdirectory tree there.




More information about the Python-list mailing list