bundles / IPython 9.12.0 / IPython / core / magics / execution / ExecutionMagics / code_wrap
function
IPython.core.magics.execution:ExecutionMagics.code_wrap
Signature
def code_wrap ( self , line , cell = None ) Summary
::
Extended Summary
%code_wrap [--remove] [--list] [--list-all] [name]
Simple magic to quickly define a code transformer for all IPython's future input.
__code__ and __ret__ are special variable that represent the code to run and the value of the last expression of __code__ respectively.
Examples
.. ipython:: In [1]: %%code_wrap before_after ...: print('before') ...: __code__ ...: print('after') ...: __ret__ In [2]: 1 before after Out[2]: 1 In [3]: %code_wrap --list before_after In [4]: %code_wrap --list-all before_after : print('before') __code__ print('after') __ret__ In [5]: %code_wrap --remove before_after positional arguments: name options: --remove remove the current transformer --list list existing transformers name --list-all list existing transformers name and code templateAliases
-
IPython.core.magics.ExecutionMagics.code_wrap