In using variables in the command line from a notebook cell, I saw that we can use put a $ in front of the variable, or surround the variable using {} , for example
!command {variable}
or
!command $variable
But when I was running a python script using the command line from a notebook cell, I would get errors
variable1 = '/path/to/directory'
variable2 = 7
!Script.py -arg1 $variable1 -arg2 $variable2
and
!Script.py -arg1 {variable1} -arg2 {variable2}
did not work.
After experimenting a little bit, I found that if a variable is a string, surrounding the whole arg with quotes got it to work.
variable1 = '/path/to/directory'
variable2 = 7
!Script.py -arg1 '$variable1' -arg2 $variable2
What is going on? I tried to look up this phenomena but I couldn't find anything.
If it makes a difference, I am using google colab colaboratory