title: Use a Glob() in VariantDir() einvironment to find files recursively in Python?
body: <p>How can one make recursive <code>Glob()</code> in a <code>VariantDir()</code> environment in Python?</p>
  
  <p>The answer from the question &lt;<a href="https://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python">Use a Glob() to find files recursively in Python?</a>> will not work, because you need use <code>Glob()</code> to get a list of files that is aware of <code>VariantDir()</code> environment.</p>
  
  <p>So you need something like:</p>
  
  <pre class="lang-py prettyprint-override"><code>import fnmatch
  import os
  
  matches = []
  for root, dirnames, filenames in os.walk('src'):
    for filename in fnmatch.filter(filenames, '*.c'):
      matches.append(os.path.join(root, filename))
  
  matches = Glob(matches)
  </code></pre>
  
  <p>Will this work?</p>