Python novice here. I'm attempting to pass a tuple of large numpy arrays to a script for processing, so I need to use their variable names to pass them from the IPython terminal.
The capability I'm looking for can be simplified to the following:
Suppose script.py is a script that simply prints the variable passed to it.
>>> var_name = (1,True)
>>> %run script.py var_name
(1,True)
var_name here is a variable that is known by and created by the IPython terminal. As of yet, I've only succeeded in returning "var_name" or Namespace(data=('var_name',)) in attempts at using sys.argv[1] or argparse.
Latest attempt:
import sys
data = tuple(sys.argv[1])
print data
The result:
>>> t = (1, True, 3.5, "hi")
>>> t
(1, True, 3.5, "hi")
>>> %run script.py t
('t',)
In MATLAB, the task of importing is simply accomplished in the first line:
function[] = scriptName(inputVar)
disp(inputVar)
Calling the script from the MATLAB terminal would look something like this:
>> scriptName(700)
700
inputVar can be an int, double, string, matrix, etc.
Is there an equivalent action in Python? Must I be using sys.argv[1] or argparse incorrectly? I know this is a beginner's question, but in the past 2 hours of searching and reading, I've found no solutions.
Thanks!