是否有等价于 Mathematica 的“用法"?功能? [英] Is there an equivalent to Mathematica's "usage" function?
本文介绍了是否有等价于 Mathematica 的“用法"?功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在数学中,可以定义一个函数的标签,例如
In Mathematicy, one can define tags of a function such as
f::usage = "f[x] gives (x - 1)(x + 1)";
然后可以这样调用:
?f
SymPy 中是否有等价物?
Is there an equivalent in SymPy?
推荐答案
您可以猴子补丁"文档字符串如下:
You can "monkey patch" the docstring as follows:
import sympy
f = sympy.Function("f")
f.__doc__ = "A naked function without any special properties"
您可以以相同的方式检索文档字符串,例如 print(f.__doc__)
.在 iPython 和类似的情况下,您也可以使用 f?
来获取它(连同一些其他信息).
You can retrieve the docstring in the very same way, e.g., print(f.__doc__)
. In iPython and similar, you can also use f?
to obtain it (together with some other information).
这篇关于是否有等价于 Mathematica 的“用法"?功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文