往返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>

以上是往返IPythontransform_cell的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>