How To Pass A Variable As A Command Line Argument In Ipython?
For example, I have a Python module and a iPython module, cmd.py import sys print sys.argv test.ipynb for i in range(5): %run cmd.py i When I run test.ipynb, it just print ['c
Solution 1:
the shell mode interprets everything literally (else cmd.py
would be evaluated as well). I would just do:
for i in range(5):
%run cmd.py $i
from http://ipython.readthedocs.io/en/stable/interactive/reference.html
IPython also allows you to expand the value of python variables when making system calls. Wrap variables or expressions in {braces}:
For simple cases, you can alternatively prepend $ to a variable name
Post a Comment for "How To Pass A Variable As A Command Line Argument In Ipython?"