title: Python list directory, subdirectory, and files
body: <p>I'm trying to make a script to list all directory, subdirectory, and files in a given directory.<br />
  I tried this:</p>
  <pre class="lang-py prettyprint-override"><code>import sys, os
  
  root = &quot;/home/patate/directory/&quot;
  path = os.path.join(root, &quot;targetdirectory&quot;)
  
  for r, d, f in os.walk(path):
      for file in f:
          print(os.path.join(root, file))
  </code></pre>
  <p>Unfortunatly it doesn't work properly.<br />
  I get all the files, but not their complete paths.</p>
  <p>For example if the dir struct would be:</p>
  <pre>
  /home/patate/directory/targetdirectory/123/456/789/file.txt
  </pre>
  <p>It would print:</p>
  <pre>
  /home/patate/directory/targetdirectory/file.txt
  </pre>
  <p>What I need is the first result. Any help would be greatly appreciated! Thanks.</p>