我试图让我的ipython别名持久化,并且根据文档,%store magic函数提供此功能.但这对我不起作用.
wim@SDFA100461C:/tmp$ echo 'print("hello world!")' > test.py wim@SDFA100461C:/tmp$ ipython In [1]: alias potato python /tmp/test.py In [2]: potato hello world! In [3]: %store potato Alias stored: potato (python /tmp/test.py) In [4]: Do you really want to exit ([y]/n)? wim@SDFA100461C:/tmp$ ipython In [1]: potato --------------------------------------------------------------------------- NameError Traceback (most recent call last)in () ----> 1 potato NameError: name 'potato' is not defined
我正在使用IPython 1.1.0/Python 2.7.5+
您需要运行%store -r
以检索存储的变量(和别名).
当然,您可以将其添加到ipython启动脚本中.