[Tutor] Data Directory under site-packages

Greg Lindstrom Greg.Lindstrom at NovaSysHealth.com
Wed Nov 10 21:36:47 CET 2010


Hello,

I'm writing my first module that I intend to put under our company's "site-packages" directory for everyone to use in their programs.  The problem I'm having is that I want to place files in a data directory under the module directory (under site-packages) and I don't know how to set the path so I pick up the files.  If I use open('./data/myfile') I get the path of the file importing the module (which could be just about anywhere).  I've tried various combinations using os.path.abspath() and os.path.dirname() but have the same problem.  Is there a way I can use files in the subdirectory (I really do not want dozens more files in the main directory)?

Thanks for your help,
--greg



CONFIDENTIALITY NOTICE:  This communication contains information 
intended for the use of the individuals to whom it is addressed 
and may contain information that is privileged, confidential or 
exempt from other disclosure under applicable law.  If you are 
not the intended recipient, you are notified that any disclosure, 
printing, copying, distribution or use of the contents is prohibited.  
If you have received this in error, please notify the sender 
immediately by telephone or by returning it by return mail and then 
permanently delete the communication from your system.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101110/cad4315c/attachment.html>


More information about the Tutor mailing list