Jupyter notebook exclamation mark arguments

Viewed 647

In jupyter notebook, we can execute a shell command using the exclamation mark, such as:

!ls *.png

I am looking for a way to pass arguments to this command, something like:

extention='*.png'
!ls %extention

I know this is possible using os.system or subprocess.check_output, but I want to use the exclamation mark as this will give me live output.

1 Answers

This is possible using {}, such as:

extention='*.png'
!ls {extention}
Related