os.walk to find path to file issue (Python 2.7)
Question: I've just starting using python 2.7 and was using the following code to
ascertain the path to a file:

    
    
    import os, fnmatch
    
    #find the location of sunnyexplorer.exe
    def find_files(directory, pattern):
        for root, dirs, files in os.walk(directory):
            for basename in files:
                if fnmatch.fnmatch(basename, pattern):
                    filename = os.path.join(root, basename)
                    yield filename
    
    for filename in find_files('c:\users','*.sx2'): 
        print ('Found Sunny Explorer data in:', filename)
    

everthing seemed to be working fine until I tried to use the path and noticed
an error. The program reports the path as:

    
    
    c:\users\woody\Documents\SMA\Sunny Explorer
    

whereas the correct path is:

    
    
    c:\users\woody\My Documents\SMA\Sunny Explorer
    


Answer: All versions of MS Windows since Vista store a user's documents in
`C:\Users\%username%\Documents` by default.

However, they also include an [NTFS junction
point](http://en.wikipedia.org/wiki/NTFS_junction_point)
`C:\Users\%username%\My Documents` which points to the same location for
backward compatibility.

The problem is, as I understand it, that you can't work with junction points
with standard POSIX calls, so Python will not be able to use them without some
Windows-specific extension module.

See also [this question](http://superuser.com/questions/194500/how-to-link-my-
documents-folder-to-the-logical-documents-folder-in-windows-7) on
superuser.com.

