title: Managing the paths of a directory tree in python
body: <p>I have a python script that keeps track of several directory names as individual variables. Some of these directories may exist, while others may need to be created at execution time.</p>
  
  <p>For example, if I have this directory tree:</p>
  
  <pre><code>./top
       /a
         /a1
         /a2
       /b
         /b1
       /c
  </code></pre>
  
  <p>then I currently track all the directory path names with individual variables:</p>
  
  <pre><code>top_path = os.path.join(os.curdir, 'top')
  a_path = os.path.join(top_path, 'a')
  # etc...
  </code></pre>
  
  <p>but it would be nice to organise them in some way that respects the directory tree, if not actual OS directory support.</p>
  
  <p>Is there some standard way of managing a directory tree (or any tree of variables) in python? Or should I just store everything in a nested list or tuple, or even make my own class? Something with a nice API like <code>top.a.a1</code> returning './top/a/a1' would be great.</p>