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...?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With