Both !
and %
allow you to run shell commands from a Jupyter notebook.
%
is provided by the IPython kernel and allows you to run "magic commands", many of which include well-known shell commands.!
, provided by Jupyter, allows shell commands to be run within cells.
I haven't been able to find much comparing the two, and for simple shell commands like cd
, etc. The main difference I see is that %
is interactive and will actually change your location in the shell while in the notebook.
Are there other points or rules of contrast when thinking about which symbol to use for shell commands in a Jupyter notebook?
!
is not provided by Jupyter: it is also provided by the IPython kernel. – prosoitos Sep 9 '20 at 22:01