有一个带有帮助功能的模块吗?

huangapple go评论59阅读模式
英文:

Is there a module with a help function?

问题

在Python嵌入版本中,我知道这听起来很奇怪,但在那里没有帮助函数。是否有一个模块可以显示关于函数和类的帮助信息?

英文:

I am using the python embedded version, and I know that this sounds weird, but in there, there isn't a help function.

Is there a module that can show help about functions and classes?

答案1

得分: 2

以下是要翻译的内容:

这个答案
> help()函数只会显示你调用它的对象的docstring。如果该对象没有docstring(或者docstring中没有你需要的信息),你需要查看所使用的模块/函数/对象的文档。

所以看起来你受限于Python版本随附的文档数量。但考虑到它是一个嵌入式版本,你运行的系统可能没有足够的存储空间来实际存储文档。如果help()未定义,那么我怀疑首先根本没有docstring。如果你能让help()工作,那么它也不会有任何文档可以访问。

与其组合一个临时的help()函数,你可能更好地使用另一台计算机并在线阅读文档。

现在,如果docstring确实存在,那就在.__doc__属性中,help()函数实际上只是读取docstring并以漂亮的方式显示出来。所以你只需要以你认为漂亮的方式显示.__doc__。你也可以尝试使用CPython的help()实现,通过使用/移植pydoc

英文:

From this answer:
> The help() function only displays the docstring of the object you're calling it on. If that object doesn't have one (or one that doesn't contain the information you're after), you will need to look at the documentation of the module/function/object you're using.

So it seems that you're pretty much limited to however much documentation your Python version ships with. But, considering that it's an embedded version, the system you're running on likely doesn't have enough storage to make storing documentation practical. If help() is undefined, then I doubt that there are any docstrings in the first place. If you were to get help() to work, then there wouldn't be any documentation for it to access anyway.

Rather than getting together a makeshift help() function, you're probably better off just using a different computer and reading the documentation online.

Now if the docstrings do exist, that is in the .__doc__ property, all the help() function really does is read the docstring and display it in a pretty way. So all you need to do is display the .__doc__ in a way that looks pretty to you. You could also try to use CPython's help() implementation by using/porting pydoc.

huangapple
  • 本文由 发表于 2023年5月15日 06:29:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76249941.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定