This documentation is for a development version of IPython-extensions. There may be significant differences from the latest stable release.
Magic to not execute a cell.
This magic can be used to mark a cell (temporary) as inactive.
In : %load_ext ipyext.inactive 'inactive' magic loaded. In : %%inactive ...: print("code not run...") ...: Cell inactive: not executed!
Writes the content of the cell to a file and then executes it.
This magic can be used to write the content of a cell to a .py file and afterwards execute the cell. This enables to code reuse.
Code is replaced on the next execution (using the needed identifier) and other code can be appended by using the same file name.
- -i <identifier> : str
- Surrounds the code written to the file with a line containing the identifier. The use of an identifier enables you to easily overwrite a given code section in the output file.
- <filename> : str
- The file to which the code should be written. Can be
specified without an extension and can also include a directory
- -d : (optional)
- Write some debugging output. Default: – (no debugging output)
In : %load_ext ipyext.writeandexecute 'writeandexecute' magic loaded. In : %%writeandexecute -i my_code_block functions.py ...: print "Hello world" ...: Hello world
In addition to executing (and printing “Hello world”), it would also create a file “functions.py” with the following content
# -*- coding: utf-8 -*- # -- ==my_code_block== -- print "Hello world" # -- ==my_code_block== --
Cell content is transformed, so
%magiccommands are executed, but
get_ipython()must be available, i.e. the code must be executed in an IPython session.