Pydoc not seeing docstrings?

£可爱£侵袭症+ 提交于 2020-02-03 05:19:12

问题


Obviously I am missing something serious here. Here is my test program:

"""
Doc and nothing but doc
"""

class TestMe(object):
    """
    class documentation goes here
    """
    def testFunc(self):
        """
        FunctionDoc Goes here
        """
        print "Hello world"

if __name__ =="__main__":
    t=TestMe()
    t.testFunc()

I run it and it prints "Hello world", natch. But pydoc.py test.py gives this:

no Python documentation found for 'test.py'

Obviously I am missing something simple here, but what?

--edit-- Per Vishnu's suggestion I added "print t.__doc__" to the last line of the file and now running the file gives this:

Hello world

    class documentation goes here

But pydoc still does not find any documentation.


回答1:


Pydoc wants a module name, not a file name. Try pydoc test.

It will use the argument as a file name if it has a slash in it: pydoc ./test.py



来源:https://stackoverflow.com/questions/27150481/pydoc-not-seeing-docstrings

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