<p>I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process. </p>

<p>For example, let's say I have three files. Using <a href="http://docs.python.org/library/functions.html#execfile" rel="noreferrer">execfile</a>:</p>

<ul>
<li><code>script_1.py</code> calls <code>script_2.py</code>. </li>
<li>In turn, <code>script_2.py</code> calls <code>script_3.py</code>. </li>
</ul>

<p>How can I get the file name and path of <strong><code>script_3.py</code></strong>, <em>from code within <code>script_3.py</code></em>, without having to pass that information as arguments from <code>script_2.py</code>?</p>

<p>(Executing <code>os.getcwd()</code> returns the original starting script's filepath not the current file's.)</p>

It's not entirely clear what you mean by "the filepath of the file that is currently running within the process".
```
sys.argv[0]
```
usually contains the location of the script that was invoked by the Python interpreter.
Check the
sys documentation
for more details.
As @Tim and @Pat Notz have pointed out, the __file__ attribute provides access to
the file from which the module was
  loaded, if it was loaded from a file