Default path for writing a file (in PythonWin)
dbrown2 at yahoo.com
dbrown2 at yahoo.com
Wed Feb 5 06:47:20 CET 2003
Carlos Ribeiro <cribeiro at mail.inet.com.br> wrote in message news:<mailman.1044324787.21766.python-list at python.org>...
> On Monday 03 February 2003 06:52 pm, dbrown2 at yahoo.com wrote:
> > What should be the default path for myfile.write(mystring) if I use
> > myfile = file('thefile','w')? It looks like files are going to a
> > library or package directory for me. Is this a Python setting of
> > PythonWin? Is there a way to change it?
> I just use os.chdir in the top of my projects:
> import os
> os.chdir( <defaultdir> )
> Of course, this code assumes that I know the path to the directory where your
> files will be located. If all you know is that you want your files to be
> located at the same directory where your script is located (or a location
> relative to that one, for instance), but you *don't* know where the actual
> script is (for example, the user simple copied the file to a different dir,
> and then started the script from the command line from a different
> directory)... it's still possible, but it may be a little more difficult;
> you'll probably need to check sys.argv, and then derive the path
> information from what you get here.
> > Also, I have not been able to get a startup file to work in PythonWin.
> > I guess I need a specific description of where to place the startup
> > file, what to name it, etc.
> There is a script just for this - sitecustomize.py - that is optional, but it
> will be loaded automatically during the Python startup. Please check the
> documentation of the 'site' standard module in the standard Python docs; it
> will explain it in more detail, particularly how does it handle the path
> Carlos Ribeiro
I had set up a sitecustomize.py which loads automagically if
I type 'python' from the DOS prompt. It does not seem to load when I
start PythonWin. Are you using PythonWin with sitecustomize.py and
having it load properly? If so where do you put it? If I can get
this to work I'll use your other tip to set the default working
More information about the Python-list