title: Set Working Directory to Notebook Directory
body: <p>In an IPython nb, is it possible to set programmatically the working directory to the directory of the notebook?</p>
  
  <p>For example, the following code will work in a regular .py file. </p>
  
  <pre><code>import os
  # show working dir
  os.chdir(os.path.abspath('/'))
  print "initial working directory:\t", os.getcwd()
  
  # get path of script file
  scriptPath = os.path.abspath(os.path.dirname(__file__))
  
  # change working dir to dir with script file
  os.chdir(scriptPath)
  
  # show working directory
  print "final working directory:\t", os.getcwd()
  </code></pre>
  
  <p>However, I can't find the equivalent of the </p>
  
  <pre><code>__file__ 
  </code></pre>
  
  <p>variable for a ipython nb file. Is there some equivalent approach for ipynb files?</p>