[Tutor] referring to subfolders

Steve Willoughby steve at alchemy.com
Sat Jan 17 06:26:52 CET 2009


Che M wrote:
> 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'

Pathnames are relative by default.  So:
    'myfile.py'
would be the file myfile.py in the current directory.
    'subfolder/myfile.py'
would be myfile.py inside subfolder, which is below the current directory.

It's the initial / character which makes it absolute, and start from the 
root directory.



More information about the Tutor mailing list