ignoring directories in os.walk()?
<p>I wish to ignore some directories in my os.walk().</p>

<p>I do:</p>

<pre><code>folders_to_ignore = ['C:\\Users\\me\\AppData\\'];
def find_files(directory, pattern):
for root, dirs, files in os.walk(directory):
    dir[:] = [d for d in dirs if not is_folder_to_ignore(d)];
    for basename in files:
        if fnmatch.fnmatch(basename, pattern):
            filename = os.path.join(root, basename)
            print("filename=" + filename);
</code></pre>

<p>I get:</p>

<pre><code>  File "C:\Users\me\workspaces\pythonWS\FileUtils\findfiles.py", line 29, in find_files
  dir[:] = [d for d in dirs if not is_folder_to_ignore(d)];
</code></pre>

<p>TypeError: 'builtin_function_or_method' object does not support item assignment</p>

<p>Any ideas?</p>

<p>Thanks.</p>
