[SciPy-user] paths relative to a python package

Zane Selvans zane at ideotrope.org
Tue Apr 1 20:19:17 EDT 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 at 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://mail.scipy.org/pipermail/scipy-user/attachments/20080401/ae6b367f/attachment.vcf>


More information about the SciPy-User mailing list