Python Import specific file or directory
<p>I want to import file 'a' into file 'b' how to do it ? I tried with os,sys etc but it doesnt work for me. I just want to go 2 folders up and go into file a. I hope that its understable.</p>

<p>file a : C:\Web\Tests\Current\Automated tests\Common\extensions\file.py</p>

<p>file b: C:\Web\Tests\Current\Automated tests\EAW\extensions\targetFile.py</p>

<p>At top of file b, append file a path into sys.path</p>

<p>For your case, added line below into file_b.py</p>

<pre><code>sys.path.append(r'C:\Web\Tests\Current\Automated tests\Common\extensions')
import file_a
</code></pre>

python file import directory