[SciPy-user] paths relative to a python package

Zane Selvans zane@ideotrope....
Tue Apr 1 19:19:17 CDT 2008


Perfect!  Thanks!

>>  How do I, within MyModule.py tell the program to open one of the data files?
> 
> import os
> 
> dirname = os.path.dirname(os.path.abspath(__file__))
> datadir = os.path.join(dirname, 'datadir')
> 
> f = open(os.path.join(datadir, 'data1.dat'))
> 


-- 
Zane Selvans
Amateur Human
zane@ideotrope.org
303/815-6866
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/ae6b367f/attachment.vcf 


More information about the SciPy-user mailing list