Last used directory?

Michael Yanowitz m.yanowitz at kearfott.com
Wed Jul 12 07:29:18 EDT 2006


Hello:

   Is there a global or some trick I can use to have
Python remember the last directory visited?
   What I mean is suppose I have this function:

def get_filename():
    """ Returns a filename selected from a Tkinter File Selection Dialog """
    strFilename = tkFileDialog.askopenfilename(initialdir='.',
                                               filetypes=[('Python
files','*.py'),
                                                          ('All
Files','*.*')])
    return strFilename

    but instead of having initialdir='.' (current directory), I
would like it set to the last visited directory, which can be from a
previous run or even a previous day. Is that possible? If so how?


Thanks in advance:
Michael Yanowitz




More information about the Python-list mailing list