[Tutor] Closing and Open File--TkFileDialogs

W W srilyk at gmail.com
Sat Feb 7 16:23:30 CET 2009


On Sat, Feb 7, 2009 at 9:09 AM, Wayne Watson
<sierra_mtnview at sbcglobal.net>wrote:

>  Yes, amazingly enough, I'm quite familiar with basic file operations. :-)
> I'm certainly no expert at all variations of it.
> <snip>
> Now for a related question. I'm using Win XP. One of the arguments is the
> default_path. I would like it to be the same folder the program is in. How
> do I do that? "c:/.", "./",  or some variation?
>

IIRC you would use "."

In [4]: import os

In [5]: os.curdir
Out[5]: '.'

or of course, os.curdir would probably be more portable.

And just a little tidbit I discovered while working with a program that
would change directories, but I was running from inside Ipython, if you add
this to the beginning of your file:

import os
startpath = os.path.abspath(os.curdir)

and then this to the end:
os.chdir(startpath)

then it will keep your ipython environment in the directory you run the file
from.

HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090207/3129b485/attachment-0001.htm>


More information about the Tutor mailing list