ipython/ipython — pull request #2766 by bfroehle (2013-01-10 06:29:39+00:00)
Title: Define __file__ when we %edit a real file.

Old behavior:
```
In [1]: %pycat test_script.py
print(__file__)

In [2]: %edit test_script.py
done. Executing edited code...
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
176 else:
177 filename = fname
--> 178 __builtin__.execfile(filename, *where)

/home/bfroehle/src/ipython/test_script.py in ()
----> 1 print(__file__)

NameError: name '__file__' is not defined
```

New behavior:
```
In [1]: %pycat test_script.py
print(__file__)

In [2]: %edit test_script.py
done. Executing edited code...
test_script.py
```

Closes gh-2765.