title: How to get/set logical directory path in python
body: <p>In python is it possible to get or set a logical directory (as opposed to an absolute one).</p>
  
  <p>For example if I have:</p>
  
  <pre><code>/real/path/to/dir
  </code></pre>
  
  <p>and I have</p>
  
  <pre><code>/linked/path/to/dir
  </code></pre>
  
  <p>linked to the same directory.</p>
  
  <p>using os.getcwd and os.chdir will always use the absolute path</p>
  
  <pre><code>&gt;&gt;&gt; import os
  &gt;&gt;&gt; os.chdir('/linked/path/to/dir')
  &gt;&gt;&gt; print os.getcwd()
  /real/path/to/dir
  </code></pre>
  
  <p>The only way I have found to get around this at all is to launch 'pwd' in another process and read the output. However, this only works until you call os.chdir for the first time.</p>