How can I get the path of my python script?
<p>I am trying to get the path of my python script.</p>

<p>I know 'sys.argv[0] gives me the path and the name of my python script.</p>

<p>how can I just get the path?</p>

<p>I tried:</p>

<pre><code> print sys.argv[0]
    path = sys.argv[0].split("/")
    scriptpath = "".join(path[0:-1])
</code></pre>

<p>But it does not add back the path separator.</p>
