[Tutor] referring to subfolders

Che M pine508 at hotmail.com
Sat Jan 17 06:20:34 CET 2009


I have been using absolute paths in my programs, but
want to get out of the habit as I try to run them on
other computers.  I was surprised to find that this
type of reference didn't work:

path = '/subfolder/myfile.py'

But instead I did it this way and it works:

import os.path
self.currentdir = os.curdir
self.mysubfolder = os.path.join(self.currentdir, "subfolder")
path = self.mysubfolder + '/myfile.py'

Is this really the only way to do it,and so I have to import
os.path each time I have a case where I refer to a subdirectory?
It seems like something quick/built-in like the first way should 
work, or maybe I am misunderstanding something?

Thanks.

_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009


More information about the Tutor mailing list