How to document a module constant in Python?

后端 未结 8 1178
忘掉有多难
忘掉有多难 2020-12-13 11:57

I have a module, errors.py in which several global constants are defined (note: I understand that Python doesn\'t have constants, but I\'ve defined them by conv

8条回答
  •  臣服心动
    2020-12-13 12:32

    You can use hash + colon to document attributes (class or module level).

    #: Use this content as input for moo to do bar
    MY_CONSTANT = "foo"
    

    This will be picked up by some document generators.

    An example here, could not find a better one: Sphinx document module properties

提交回复
热议问题