往返IPythontransform_cell
考虑以下示例:
>>> from IPython.core.inputtransformer2 import TransformerManager
>>> src = """
... foo = !ls
... !!ls
... """
>>> TransformerManager().transform_cell(src)
"foo = get_ipython().getoutput('ls')nget_ipython().getoutput('ls')n"
双方!ls并!!ls得到转化为get_ipython().getoutput('ls')。
如果我只看到 的输出TransformerManager().transform_cell,有没有办法检索原始来源?
有没有办法判断get_ipython().get_output(<some string>)是来自!<some string>还是!!<some string>?