Popular recipes by Jitender Cheema http://code.activestate.com/recipes/users/2790517/2006-02-24T05:23:36-08:00ActiveState Code RecipesGet the path of the currently executing python script using import. (Python)
2006-02-24T05:23:36-08:00Jitender Cheemahttp://code.activestate.com/recipes/users/2790517/http://code.activestate.com/recipes/474083-get-the-path-of-the-currently-executing-python-scr/
<p style="color: grey">
Python
recipe 474083
by <a href="/recipes/users/2790517/">Jitender Cheema</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<h4>1. sys.arg has the script name</h4>
<h4>2. Although there can be many ways, e.g. os.cwd() but, there is another</h4>
<h4>trick to</h4>
<h4>obtain the Complete URI or Location of the current script.</h4>
<h4>You can argue, os.getcwd()</h4>
<h4>import can give you working directory of the current script</h4>
<h4>Third party Java code calling your script.... ;)</h4>
<p>#</p>