Hi, On 12 January 2011 13:11, Kann Vearasilp <vearas...@gmail.com> wrote:
> 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. > 1.) You should be able to use relative paths, e.g. something like: open("../data/file1", "w") 2.) You can set up configuration for your application to define where the data files live. See e.g. the "ConfigParser" module: http://wiki.python.org/moin/ConfigParser Walter
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor