title: How to fetch a specific file or directory list using os.walk in Python?
body: <p>I'd like to know if it is possible to retrieve by index number a specific file in a specific subfolder inside an os.walk class.</p>
  
  <p>I'd also like to know how can I list just the subdirs at a specific level inside the os.walk, for example just the subdirs of the root directory. I can list all subdirs and I can see that the list for the 1st level subdirs are grouped together first, but I can't find a way to filter just those out without using a loop...</p>
  
  <p>Something like this works (adapted from another question) partially but I don't know how to filter the folders from just one level:</p>
  
  <pre><code>dirs[:] = [d for d in dirs if re.match('anyname_\d{3}', d, flags=0)]
  </code></pre>
  
  <p>The os.walk tuples show as 'list' when using the type command and some errors when trying to use index numbers refer to improper use of a dictionary object. I'm confused.</p>
  
  <p>Thanks!</p>