Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/takluyver/cell2function

IPython extension to convert a cell to a function
https://github.com/takluyver/cell2function

Last synced: 4 days ago
JSON representation

IPython extension to convert a cell to a function

Awesome Lists containing this project

README

        

IPython extension to convert a cell to a function

Code that starts off as exploratory interactive code in a notebook often
solidifies into something that you want to reuse in other cells. This utility
turns a cell into a function definition. The new function expects every variable
that was used before it's defined, and returns every variable defined in that cell.
This will rarely be right, but deleting code is easier than writing it.

To use it, load the extension with ``%load_ext cell2function``, and then add
``%%cell2function`` at the top of cells you want to turn into functions. The new
functions will appear in a new cell beneath.

See `the demo notebook `_
for more information.