[英]How to rename a magic function in IPython?
I'd like to rename %paste
to something like %pp
so that it takes fewer keystrokes. 我想将%paste
重命名为%pp
以便减少击键次数。 I worked out a way to do that but it seems complicated. 我找到了一种方法,但它似乎很复杂。 Is there a better way? 有没有更好的办法?
def foo(self, bar):
get_ipython().magic("paste")
get_ipython().define_magic('pp', foo)
从IPython 0.13开始,有一个新的%alias_magic
魔术函数,您可以将其用作:
%alias_magic pp paste
use %alias
magic to do it (if you want it to be permanent use %store
): 使用%alias
magic来做它(如果你想让它永久使用%store
):
In [8]: %alias??
"""Define an alias for a system command.
'%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.