Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define __file__ when we %edit a real file. #2766

Merged
merged 1 commit into from Jan 10, 2013

Conversation

bfroehle
Copy link
Contributor

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 <module>()
----> 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.

@takluyver
Copy link
Member

Looks OK to me. Merging now. Thanks!

takluyver added a commit that referenced this pull request Jan 10, 2013
Define __file__ when we %edit a real file.
@takluyver takluyver merged commit 7a9f6c3 into ipython:master Jan 10, 2013
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Define __file__ when we %edit a real file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

name '__file__' is not defined
2 participants