path to data files

Daniel Kluev dan.kluev at gmail.com
Thu Aug 19 06:32:49 EDT 2010


On Thu, Aug 19, 2010 at 9:25 PM, Daniel Fetchinson <
fetchinson at googlemail.com> wrote:

> If a python module requires a data file to run how would I reference
> this data file in the source in a way that does not depend on whether
> the module is installed system-wide, installed in $HOME/.local or is
> just placed in a directory from where the interpreter is fired up? I'd
> like to always keep the python source and the data file in the same
> directory, be it /usr/lib/python2.6/site-packages,
> $HOME/.local/lib/python2.6/site-packages or
> /arbitrary/path/to/somewhere.
>

open(os.path.join(os.path.dirname(__file__), 'foo'))

-- 
With best regards,
Daniel Kluev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100819/9370a1a9/attachment.html>


More information about the Python-list mailing list