IPython Magics
The following was copied from https://ipython.org/ipython-doc/3/config/custommagics.html
from IPython.core.magic import register_line_magic, register_cell_magic
@register_line_magic
def lmagic(line):
"my line magic"
return line
@register_cell_magic
def cmagic(line, cell):
"my cell magic"
return line, cell
# We delete to avoid name conflicts for automagic to work
del lmagic
# Before
%lmagic Not valid python # this
# after
%%cmagic The part on the same line
The line after
The other line