私はiPythonで定義した変数をPythonスクリプトに渡したいと思います。例えばスクリプト内のiPythonの変数を使用する
:
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)
だから私は、彼らは(int型、範囲、などであるかもしれないものは何でも、iPythonでxとyの値が欲しい:スクリプトがある
In [1]: import demo
In [2]: x = [1, 2, 3]
In [3]: y = [1, 2, 3]
In [4]: rtp x y
)をスクリプトから見ることができます。このスクリプトは文字列 "xy"のみを表示します。
iPythonからスクリプトへの転送でこれらの値を取得するにはどうすればよいですか?それが不可能な場合、人々は通常回避策として何をしていますか?
ありがとうございます!私は
rtp x, y
ありがとう - これは私が探していたものです。 xとyの値を設定すると、rtp x yは正しい値を出力するようになりました。 –
N.B.ソースはずっと移動しています。https://github.com/ipython/ipython –