title: NameError: name '__file__' is not defined
body: <p>I am trying to store the path of a script into a variable using:</p>
  
  <pre><code>os.path.abspath(os.path.dirname(__file__))
  </code></pre>
  
  <p>However, it keeps returning a <code>name '__file__' is not defined</code> error.</p>
  
  <pre><code>here = os.path.dirname(os.path.abspath(__file__))
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  NameError: name '__file__' is not defined
  </code></pre>