Default path for files

Aahz aahz at
Sat Jan 30 19:59:47 CET 2010

In article <hjhnp0$7bc$1 at>,
Rotwang  <sg552 at> wrote:
>Hi all, can anybody tell me whether there's a way to change the default 
>location for files to be opened by open()? I'd like to be able to create 
>files somewhere other than my Python folder without having to write the 
>full path in the filename every time. Sorry if this is a stupid 
>question, I don't know much about programming.

from os.path import join
BASE = '/path/to/root'
f = open(join(BASE, filename))

Trust me, you'll be much happier with this.
Aahz (aahz at           <*>

import antigravity

More information about the Python-list mailing list