On Thu, 19 Aug 2010 14:30:34 +0200, Alain Ketterlin 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? > > sys.path[0] is supposed to contain the script's directory.
One caveat: if you use wxPython, wxversion.select() pushes the directory containing the selected version at the front of sys.path, so that a subsequent "import wx" will import the correct version. It's possible that other functions may do likewise, so if you're relying upon sys.path[0] to find the script's directory, it's a good idea to make a copy of sys.path[0] before importing any modules (other than sys). -- http://mail.python.org/mailman/listinfo/python-list