Get parent directory of a specific file
<p>There is a file <code>a.py</code>.</p>

<p>The location is <code>/home/user/projects/project1/xxx/a.py</code>.</p>

<p>If  I call <code>os.getcwd()</code>, it gives me <code>/home/user/projects/project1/xxx/</code>. But I want to reach <code>/home/user/projects/project1</code>. How can i do this in Python?</p>

<p><strong>Edit :</strong> I think i must be more clear. i want this for my Django project. </p>

<p>i use these codes in my settings.py:</p>

<pre><code>PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
</code></pre>

<p>then i use fallowing code to specify where my static file folder is. :</p>

<pre><code>os.path.join(PROJECT_PATH,'statics'),
</code></pre>

<p>my settings.py file is under: <code>/home/user/projects/project1/xxx/settings.py</code></p>

<p>my static file folder is under same dir as <code>settings.py</code>.</p>

<p>now i want to move this folder to <code>/home/user/projects/project1</code></p>

<p>what should i do with code that in settings.py</p>

<p>thank you</p>
