Do the triple-quoted (docstring) messages in Python appear while typing in IDEs other than IDLE?

百般思念 提交于 2019-12-24 11:14:38

问题


I usually write scripts to calculate or process things for my own consumption. Now I'm trying to write scripts for others.

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.

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.

nothing.


回答1:


The "triple-quoted messages" are docstrings, and they appear in different contexts.

For example:

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

  • When calling help on the function:

    >> help(foo)
    Help on function foo in module __main__:
    
    foo()
         foo's docstring
    


I can not tell you about other IDEs as I don't use them.



来源:https://stackoverflow.com/questions/53988820/do-the-triple-quoted-docstring-messages-in-python-appear-while-typing-in-ides

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