title: Navigate directories in Python without changing the current directory?
body: <pre><code>C:/Root
    |__WinPython
    |     |_WinPy
    |           |_Python(Working Directory)
    |                 |_sample.py
    |__SDK
        |_SparkHome    
  </code></pre>
  
  <p>Consider I'm in the Working directory mentioned above.</p>
  
  <pre><code>os.getcwd()
     C:/Root/WinPython/WinPy/Python
  </code></pre>
  
  <p>Now I need to set the Spark Home from the sample.py file in current directory, which should be like </p>
  
  <pre><code>Spark_Home="Root/SDK/SparkHome"    
  </code></pre>
  
  <p>I achieved this using the command,</p>
  
  <pre><code>import os
  spark_home = os.chdir("../../../SDK/SparkHome")
  </code></pre>
  
  <p>This sets the spark home for me successfully but also changes the current working directory.</p>
  
  <pre><code>os.getcwd()
    C:/Root/SDK/SparkHome
  </code></pre>
  
  <p>Does anyone know how to achieve this without changing the current working directory?</p>