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

%%writefile seems to work differently when running ipython vs ipython notebook for a blank line at the end of a file #8626

Open
donnemartin opened this issue Jul 11, 2015 · 0 comments
Milestone

Comments

@donnemartin
Copy link

IPython

If I use the simple snippet below in IPython, which I run from my bash terminal (blank line intentional):

%%writefile foo.py
print('hello world')

I get the expected blank line at the end of the file foo.py which is helpful for some tools and for PEP-8 compliance.

IPython Notebook

If I use the same code in an IPython Notebook cell and run it, I do not get the blank line.

I would have to do the following in a notebook to get the equivalent foo.py (two blank lines intentional):

%%writefile foo.py
hello world


Checking the %%writefile docs didn't turn up an option that might address this.

Environment

I'm running Python 2.7.10 and the following:

$ pip freeze
backports.ssl-match-hostname==3.4.0.2
certifi==2015.4.28
functools32==3.2.3.post1
gnureadline==6.3.3
ipython==3.2.0
Jinja2==2.7.3
jsonschema==2.5.1
MarkupSafe==0.23
matplotlib==1.4.3
mistune==0.6
mock==1.0.1
nose==1.3.7
numpy==1.9.2
pandas==0.16.2
ptyprocess==0.5
Pygments==2.0.2
pyparsing==2.0.3
python-dateutil==2.4.2
pytz==2015.4
pyzmq==14.7.0
scikit-learn==0.16.1
scipy==0.15.1
seaborn==0.6.0
six==1.9.0
sympy==0.7.6
terminado==0.5
tornado==4.2
wheel==0.24.0

@takluyver takluyver added this to the wishlist milestone Jan 26, 2016
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

No branches or pull requests

2 participants