To Skip A Cell From Running (e.g. work in progress)
Add at the top of the cell:
%%script false
some multiline code
that you want to skip for a time being
(e.g. work in progress)
without commenting out / deleting cell
goes here
%%script false
update 2020-01-19: the above no longer works. see below for new solutions.
Since that behavior was never documented (or was intended to work) they must have dropped it in the recent versions of ipython.
I’m not sure why I no longer am able to edit my posts here, but here are workarounds, based on programs ignoring their arguments when you tell them not to expect any. Here are some easy examples:
Perl:
%%perl -e0
for i in range(10): print(i)
Here you’re running: perl -e '0' cellcontents
A more memorable version:
%%perl -eat
for i in range(10): print(i)
Here you’re running: perl -e 'at' cellcontents
Bash:
%%bash -c :
for i in range(10): print(i)
‘:’ is a noop in bash, so you’re running: bash -c : cellcontents
I haven’t looked at the external magic implementation code, but I’m pretty sure “cellcontents” are passed as arguments and won’t be interpreted by shell by mistake, say if you were to include ‘;’ in them and accidentally inject some bad code. But I can’t guarantee you that.
I’m sure you can come up with other creative solutions, by looking at the supported programs here: https://ipython.readthedocs.io/en/stable/interactive/magics.html#cell-magics