Skip to content
IPython extension to convert a cell to a function
Python
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
Cell2function demo.ipynb
README.rst
cell2function.py
test_cell2func.py

README.rst

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.

Something went wrong with that request. Please try again.