title: Need help using python subprocess module to navigate Linux directories
body: <p>First off, I know there are FAR better ways to do this. I'm trying to learn the most basic behavior of subprocess.Popen() when it interacts with various UNIX commands. I'm doing something wrong with directory navigation, and I have no idea what it is. I'm running iPython as my REPL, so the ls command shows the files in the current working directory. </p>
  
  <p>Someone please tell me what I'm doing wrong! </p>
  
  <pre><code>In [61]: newtree_dirs
  Out[61]:
  ['10dir',
   '1dir',
   '2dir',
   '3dir',
   '4dir',
   '5dir',
   '6dir',
   '7dir',
   '8dir',
   '9dir']
  
  In [62]: ls
  10dir/  1dir/  2dir/  3dir/  4dir/  5dir/  6dir/  7dir/  8dir/  9dir/
  
  In [63]: for folder in newtree_dirs:
      ...:     p1 = sub.Popen(['cd', './{}'.format(folder)])
      ...:     p1.communicate()
      ...:     foo = (i for i in xrange(10))
      ...:     for num in foo:
      ...:         p2 = sub.Popen(['touch', '{}file'.format(num)])
      ...:         p2.communicate()
      ...:     p3 = sub.Popen(['cd', '..'])
      ...:     p3.communicate()
      ...:
      ...:
  ---------------------------------------------------------------------------
  OSError                                   Traceback (most recent call last)
  &lt;ipython-input-63-bb6e77faf97b&gt; in &lt;module&gt;()
        1 for folder in newtree_dirs:
  ----&gt; 2     p1 = sub.Popen(['cd', u'./{}'.format(folder)])
        3     p1.communicate()
        4     bar = (i for i in xrange(10))
        5     for num in bar:
  </code></pre>
  
  <p>after that exception, further exceptions descend into the subprocess module's error handling for a missing directory. The directory names in my cwd are identical and I don't know what's going on. </p>