pythoncomments

What is the Pythonic way to create informative comments in Python?


For further clarification, C# has the '///' directive which invokes the super-secret-styled Comments which allow you to have nice comments built into intellisense. Java has the '@' directive that allows you to have nice comments as well.

Does Python have something like this?


Solution

  • In python a docstring can be viewed via commands.

    class myClass:
        """
          This is some documentation for the class.
          method1()
          method2()
        """
        def method1(p1):
            ....
            ...
            ...
        def method2():
            ...
            ...
    
    v = myClass
    

    you can then view the docstring by using either

    v.__doc__
    

    or

    help(myClass)