title: How to resolve relative paths in python?
body: <p>I have Directory structure like this</p>
  
  <pre><code>projectfolder/fold1/fold2/fold3/script.py
  </code></pre>
  
  <p>now I'm giving script.py a path as commandline argument of a file which is there in </p>
  
  <pre><code>fold1/fold_temp/myfile.txt
  </code></pre>
  
  <p>So basically I want to be able to give path in this way </p>
  
  <pre><code>../../fold_temp/myfile.txt 
  
  &gt;&gt;python somepath/pythonfile.py -input ../../fold_temp/myfile.txt
  </code></pre>
  
  <p>Here problem is that I might be given full path or relative path so I should be able to decide and based on that I should be able to create absolute path.</p>
  
  <p>I already have knowledge of functions related to path. </p>
  
  <p><a href="https://stackoverflow.com/questions/918154/relative-paths-in-python">Question 1</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1270951/python-how-to-refer-to-relative-paths-of-resources-when-working-with-code-repo">Question 2</a></p>
  
  <p>Reference questions are giving partial answer but I don't know how to build full path using the functions provided in them. </p>