在非IDLE的IDE中键入时,Python中是否出现三引号(文档字符串)消息? [英] Do the triple-quoted (docstring) messages in Python appear while typing in IDEs other than IDLE?
问题描述
我通常会编写脚本来计算或处理自己需要的东西.现在,我正在尝试为其他人编写脚本.
I usually write scripts to calculate or process things for my own consumption. Now I'm trying to write scripts for others.
我同时使用IDLE和终端,但是我喜欢IDLE界面,发现它更有用.今天,我发现"可以在class
和def
下添加三引号的文本,并在使用IDLE时实时查看它们,并且我意识到我可以使用它们来帮助其他人知道如何使用这些类和方法.
I use both IDLE and a terminal, but I like just like the IDLE interface and find it more helpful. Today I "discovered" that I can add triple-quoted text under class
and def
and see them in real time when using IDLE, and I realize I can use those to help others know how to use these classes and methods.
但是,如果从终端运行,这一切都将丢失.
But if run from a terminal this is all lost.
问题:是只有IDLE用户在键入使用类或方法的行时看到了这些提示,还是人们使用终端的东西? 是否可以在键入内容时看到他们想要的内容?我知道例如可以键入A.__doc__
来查看它,但是弹出窗口确实非常方便且有用.
Question: Is it only IDLE users who are seeing these cues while they are typing a line that uses the class or method, or is this something that people using terminal could see while typing if they wanted to? I know that one could type A.__doc__
to see it for example, but the pop-up window is really convenient and helpful.
class A(object):
"""hey A!"""
def __init__(self, x):
"""hey __int__!"""
self.x = x
def sqrx(self):
"""hey sqrx!"""
print self.x**2
(只是看看会发生什么情况)
(just to see what would happen if)
但是,如果我从终端执行此操作,所有这些提示将消失.
But if I do this from a terminal all these prompts disappear.
什么都没有.
推荐答案
三重引用消息"为文档字符串,它们出现在不同的上下文中.
The "triple-quoted messages" are docstrings, and they appear in different contexts.
例如:
When hitting ctrl+q (or whatever key is bound to the "Quick Documentation" action) in PyCharm:
还有一个选项可以在键入时显示快速的文档弹出窗口.
There is also an option to display the quick documentation pop-up while typing.
在函数上调用help
时:
>> help(foo)
Help on function foo in module __main__:
foo()
foo's docstring
我不向您介绍其他IDE,因为我不使用它们.
I can not tell you about other IDEs as I don't use them.
这篇关于在非IDLE的IDE中键入时,Python中是否出现三引号(文档字符串)消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!