admin管理员组文章数量:1332389
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?
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?
1 Answer
Reset to default 11After talking with the IPython dev team minrk found an answer:
%%writefile filename.py
will write everything below it in the cell to filename.py
. link to the converastion.
本文标签: javascriptSave by cell and not by lineIPython save magic Is there a wayStack Overflow
版权声明:本文标题:javascript - Save by cell and not by line #: IPython %save magic: Is there a way? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742286354a2446999.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论