How to document a method with parameter(s)?

前端 未结 8 1783
情书的邮戳
情书的邮戳 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:09

    python doc strings are free-form, you can document it in any way you like.

    Examples:

    def mymethod(self, foo, bars):
        """
        Does neat stuff!
        Parameters:
          foo - a foo of type FooType to bar with.
          bars - The list of bars
        """
    

    Now, there are some conventions, but python doesn't enforce any of them. Some projects have their own conventions. Some tools to work with docstrings also follow specific conventions.

提交回复
热议问题