Is there an equivalent to Mathematica's “usage” function?

谁说胖子不能爱 提交于 2019-12-12 04:20:39

问题


In Mathematicy, one can define tags of a function such as

f::usage = "f[x] gives (x - 1)(x + 1)";

which can then be called like:

?f

Is there an equivalent in SymPy?


回答1:


You can “monkey patch” the docstring as follows:

import sympy
f = sympy.Function("f")
f.__doc__ = "A naked function without any special properties"

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).



来源:https://stackoverflow.com/questions/43715293/is-there-an-equivalent-to-mathematicas-usage-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!