[Tutor] Ideas about global variables for accessing project's file

Kann Vearasilp vearasilp at gmail.com
Wed Jan 12 14:11:34 CET 2011


Dear all,

I am new to python and now having a tiny problem about accessing files from
python modules I have in my project.. Here is my situation:

Below is the structure of my project

/src
/src/modules/mod1
/src/modules/mod2
/src/data/file1
/src/data/file2


I wrote some codes in mod1 to access data in file1. And to read the file1, I
am hard coding in the mod1, which is something like...
open(blahblah/src/data/file1, "w")
Now the problems arise when I share my code with other collaborators and the
code is not working any more because his/her blahblah before /src is
different.

Is there a way to make a global variable for the project to make my life
easier? Sometime like... PROJECT_PATH/src/modules/mod1 which PROJECT_PATH
should work with every machines.

All suggestions and advices will be much appreciated.

Kann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110112/73de83d9/attachment.html>


More information about the Tutor mailing list