How to document a method with parameter(s)?

前端 未结 8 1798
情书的邮戳
情书的邮戳 2020-12-07 07:52

How to document methods with parameters using Python\'s documentation strings?

EDIT: PEP 257 gives this example:

d         


        
8条回答
  •  佛祖请我去吃肉
    2020-12-07 08:15

    Docstrings are only useful within interactive environments, e.g. the Python shell. When documenting objects that are not going to be used interactively (e.g. internal objects, framework callbacks), you might as well use regular comments. Here’s a style I use for hanging indented comments off items, each on their own line, so you know that the comment is applying to:

    def Recomputate \
      (
        TheRotaryGyrator,
          # the rotary gyrator to operate on
        Computrons,
          # the computrons to perform the recomputation with
        Forthwith,
          # whether to recomputate forthwith or at one's leisure
      ) :
      # recomputates the specified rotary gyrator with
      # the desired computrons.
      ...
    #end Recomputate
    

    You can’t do this sort of thing with docstrings.

提交回复
热议问题