Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Feature request: Save by cell and not by line #: IPython %save magic #3426

Closed
agconti opened this Issue · 8 comments

2 participants

@agconti

I'm creating a Django tutorial in an IPython Notebook and I want to use the %save magic to save .py files to create / edit / advance a website as the tutorial progresses. The problem is the %save magic works by specifying which lines to save. Undoubtedly, the line number will change when users execute the cells before the file out of order or multiple times.

I'd like to work like this:

some .py file imported into the notebook.
# do all sorts of website things
%save -f this.py file

where it would save the contents of the cell without needing the line number. Is there any way to do this with the existing functionality of the %save magic? If not, does anyone else have a need for such a feature?

@minrk
Owner

The notebook is for editing notebooks - if you want to export a notebook to a Python script, that is already provided by the 'save as .py' facility of the notebook.

@agconti

I don't want to save the entire notebook. Just certain.py files I've loaded in with %loadpy. You can see a rough example of what I mean here on line 39 in the notebook.

@agconti

With this kind of feature you would be able to interactively develop and manage your projects from the same place.

@minrk
Owner

Ah, I thnk get it. So basically you want to open/edit/save whole scripts from the notebook UI? We do plan to add that before too long.

@agconti

Exactly. Is there any current work on it? I'd like to contribute.

@minrk
Owner

There was a full-page ACE tested a while ago, and something similar will probably come in, but it will have to be done after IPEP 16.

@minrk
Owner

For now, the closest equivalent workflow is to load a cell with %load, and then write it again with %%writefile filename.py

@agconti

Hi @minrk,

%%writefile filename.py works perfectly and saves everything in the cell. How can I update the documentation to reflect this? Thanks a lot for your help!

@agconti agconti closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.