[SciPy-user] paths relative to a python package

Zane Selvans zane@ideotrope....
Tue Apr 1 18:37:31 CDT 2008

I know this isn't scipy specific but...

If you have a data file that's distributed with a python package, how do 
you refer to it relative to the location that the package ultimately 
gets installed?  Is there a package_root variable or something?

e.g. in my package directory let's say I have:


and within datadir:


How do I, within MyModule.py tell the program to open one of the data files?

If I just do open('datadir/data1.dat') it'll try and open that dir/file 
relative to wherever the python program that imported MyModule is 
running, right?  Which isn't what I want.

Thanks for any insight,

Zane Selvans
Amateur Human
PGP Key: 55E0815F
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zane.vcf
Type: text/x-vcard
Size: 254 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20080401/53aa6629/attachment.vcf 

More information about the SciPy-user mailing list