问题
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