title: When to use Absolute Path vs Relative Path in Python
body: <p>For reference. The absolute path is the full path to some place on your computer. The relative path is the path to some file with respect to your current working directory (PWD). For example:</p>
  
  <p>Absolute path: 
  <code>C:/users/admin/docs/stuff.txt</code></p>
  
  <p>If my PWD is <code>C:/users/admin/</code>, then the relative path to <code>stuff.txt</code> would be: <code>docs/stuff.txt</code></p>
  
  <p>Note, PWD + relative path = absolute path.</p>
  
  <p>Cool, awesome. Now, I wrote some scripts which check if a file exists.</p>
  
  <p><code>os.chdir("C:/users/admin/docs")
   os.path.exists("stuff.txt")</code></p>
  
  <p>This returns <code>TRUE</code> if <code>stuff.txt</code> exists and it <em>works</em>.</p>
  
  <p>Now, instead if I write,</p>
  
  <p><code>os.path.exists("C:/users/admin/docs/stuff.txt")</code></p>
  
  <p>This also returns <code>TRUE</code>. </p>
  
  <p>Is there a definite time when we need to use one over the other? Is there a methodology for how python looks for paths? Does it try one first then the other?</p>
  
  <p>Thanks!</p>