我正在尝试更新找到here的脚本以使用IPython 0.13.1,并且达到了停顿状态。该脚本调用
import IPython.ipapi
ip = IPython.ipapi.get()
for var in self.magic_who_ls():
try:
pickle.dump(user_ns[var],fout,1)
saved_vars.append(var)
except:
# An object that cannot be pickled was encountered
print("Unable to save object: %s" % var)
我知道 IPython.ipapi 已移至 IPython.core.ipapi , expose_magic 已重命名为 define_magic 和 magic_who_ls 已重命名为 who_ls ,但我无法从脚本中调用 who_ls 来获取命名空间变量列表。谁能给我一个提示?
答案 0 :(得分:2)
import IPython
ip = IPython.core.ipapi.get()
for var in ip.run_line_magic('who_ls', ''):
# potato