I would like to define a variable in a Jupyter notebook and then pass it to a python script.
For example, in the notebook:
a = [1, 2, 3, 4]
%run example.py
print foo
And in example.py
b = [5, 8, 9, 10]
foo = a + b
Of course, this returns an error because a has not been defined in example.py. However, if example.py has instead
a = [1, 2, 3, 4]
b = [5, 8, 9, 10]
foo = a + b
Then the Jupyter notebook can "see" foo after the script is run and print it, even though foo was not defined in the Jupyter notebook itself.
Why can't the python script see variables in the Jupyter notebook environment? And how can I pass a variable from the notebook environment to the script?