title: How to access file in parent directory using python?
body: <p>I am trying to access a text file in the parent directory, </p>
  
  <p>Eg : python script is in <strong>codeSrc</strong> &amp; the text file is in <strong>mainFolder</strong>.</p>
  
  <h3>script path:</h3>
  
  <pre><code>G:\mainFolder\codeSrc\fun.py
  </code></pre>
  
  <h3>desired file path:</h3>
  
  <pre><code>G:\mainFolder\foo.txt
  </code></pre>
  
  <p>I am currently using this syntax with python 2.7x,</p>
  
  <pre><code>import os 
  filename = os.path.dirname(os.getcwd())+"\\foo.txt"
  </code></pre>
  
  <p>Although this works fine, is there a better (prettier :P) way to do this?</p>