I'd like to pass variables I've defined in iPython into a python script.
For example:
In [1]: import demo
In [2]: x = [1, 2, 3]
In [3]: y = [1, 2, 3]
In [4]: rtp x y
Where the script is:
import IPython.ipapi
ip = IPython.ipapi.get()
def run_this_plot(*args):
""" Run
Examples
In [1]: import demo
In [2]: rtp x y <z>
Where x, y, and z are numbers of any type
"""
print "args: ", args
# Do something here with args, such as plot them
# Activate the extension
ip.expose_magic("rtp", run_this_plot)
So I'd like the values from x and y in iPython, whatever they might be (ints, ranges, etc) to be seen from the script, which right now only sees the string "x y".
How might I obtain these values in the transfer from iPython to a script? If it's not possible, what do people usually do as a workaround?
Thanks! --Erin