Here's part of the output that's incorrect:<br><br>models\W_BoomerEdge<br>        BYOS_C.entity.xml<br>        BYOS_C_Collision.entity.xml<br><br>Notice that the file BYOS_C.entity.xml is showing up as a file in the directory W_BoomerEdge. This file does not exist in this folder, but yet in a different folder. The output is consistent with the 'print' statements you will see in the function I posted earlier.
<br><br><div><span class="gmail_quote">On 8/17/07, <b class="gmail_sendername">Robert Dailey</b> <<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I've created a function that is used to recurse a directory tree in Windows XP using os.walk(). For the most part it works, however in some instances the data is incorrect and I'm getting invalid sub-directory paths. Here's the function:
<br><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">def __doSearch( root_dir, sub_path, restype, ext ):</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">    print sub_path</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    # Searches the specified directory and generates a
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    # list of files to preload.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

    complete_path = osp.normpath( osp.join( root_dir, sub_path ) )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    for root, dirs, files in os.walk( complete_path ):
</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        # Record the list of file hash ID's</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">        for file in files:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            split = __resType( file )</span>

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            if split[1] == restype:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

#                print sub_path</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                print "\t", file</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">                __appendResource( ext, sub_path, split[0] )</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

        # Remove .svn subdirectories; we don't walk these.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        if ".svn" in dirs:</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">            dirs.remove( ".svn" )</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

        # Recurse child directories</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        for dir in dirs:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

            __doSearch( root_dir, osp.join( sub_path, dir ), restype, ext )<br><br></span><span>Does anyone see anything immediately suspicious about the code? I'm assuming that in Python, every time a function is called recursively it gets its own copy of local variables. For some reason the sub_path variable isn't consistent depending on where I use it. For example, if you notice the print call at the very start of the function, it will output something like "models/ships". However, after passing it into __appendResource(), it appears to be just "models".
</span><span style="font-family: courier new,monospace;"><br></span>
</blockquote></div><br>