Thanks for the docs link!
I’ve now managed to prepend a line like this:
def run_all_cell_with_magics(lines):
new_lines = []
new_lines.append("print('Hello Time') \n") #this works
#new_lines.append("%%timeit \n") # this does not work
for line in lines:
new_lines.append(line)
return new_lines
ip = get_ipython()
ip.input_transformers_cleanup.append(run_all_cell_with_magics)
and it actually prints “Hello Time” for every cell, as can be seen in this screenshot:
But that does not work for prepending %%timeit.
The docs also mentions that this is not possible:
Then IPython runs its own transformations to handle its special syntax, like
%magicsand!systemcommands. This part does not expose extension points.
Does that mean that this run_all_cell_with_magics function can only be implemented in IPython itself?
