Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly document class' static variables?

What is the preferred way to document static variables in classes?

class Foo(object):
    """
    Foo doc.
    """

    bar = 'bar'
    """
    Bar doc.
    """


class Foo(object):
    """
    Foo doc.
    """

    # Bar doc.
    bar = 'bar'

Something else...?

like image 793
morgoth84 Avatar asked Sep 10 '25 11:09

morgoth84


1 Answers

There is no way to associate docstrings with variables. The PEP to add attribute docstrings failed.

The best way for code documentation is probably a comment rather than a docstring, so that you aren't introducing ambiguity of the kinds that the PEP discusses. You can additionally document them in the class' docstring if you want them in help() and docs.

like image 110
otus Avatar answered Sep 13 '25 01:09

otus