file open default location

T. Crane tcrane at
Tue Jun 12 15:51:09 CEST 2007

<kyosohma at> wrote in message 
news:1181655985.895174.116540 at
> On Jun 12, 8:42 am, "T. Crane" <tcr... at> wrote:
>> Hi,
>> How is the default path chosen in this instance:
>> myFile = file('test.txt','w')
>> Here I'm opening/creating a file but I have not specified the exact path, 
>> so
>> how does Python determine where to 'put' this file?  More to the point, 
>> how
>> do I change what the default path is?  Right now it's a networked drive 
>> that
>> should not be getting my Python clutter.
>> Interestingly, this network drive is also where I can find my _ipython
>> folder from my ipython install as well as my .matplotlib folder.  Can 
>> anyone
>> tell me how to change where these folders and files go by default?
>> thanks for any help,
>> trevis
> When you don't specify where you want to save a file, it saves the
> file to the directory the script itself is run from. As far as I know,
> you have to specify where you want the file saved if you don't want it
> with the

Unfortunately, this is not the case.  My module's path is this:

C:\documents and setting\t_crane\my documents\python modules\

Python is in the directory C:\Python25

The file is being saved in this path:

K:\myFile.txt  (this is the networked drive mentioned above)

As an aside, I forgot to mention above that I'm using Windows XP.  Any other 
ideas or possible reasons that it would not choose my script location as the 
default location to save something?


More information about the Python-list mailing list