title: How is the python assignment "mylist[:] = somelist" different from "mylist = somelist"
body: <p>I'm filtering the directory components using os.walk():</p>
  
  <pre><code>exclude_dirs = ['a', 'b']
  for root, dirs, files in os.walk(mytopdir):
    dirs[:] = [d for d in dirs if d not in exclude_dirs]  # 1. Works
    dirs = [d for d in dirs if d not in exclude_dirs]     # 2. Doesn't work
  </code></pre>
  
  <p>It seems like the second one is making a new local variable which hides the original dirs.  How is the first one doing things that it avoids this?</p>