file open default location

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


<kyosohma at gmail.com> wrote in message 
news:1181655985.895174.116540 at o11g2000prd.googlegroups.com...
> On Jun 12, 8:42 am, "T. Crane" <tcr... at REMOVETHISuiuc.edu> 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 script.py

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

C:\documents and setting\t_crane\my documents\python modules\script.py

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?

thanks,
trevis 





More information about the Python-list mailing list