What is the proper way to comment functions in Python?

前端 未结 10 1586
情书的邮戳
情书的邮戳 2021-01-30 01:58

Is there a generally accepted way to comment functions in Python? Is the following acceptable?

#########################################################
# Create         


        
10条回答
  •  日久生厌
    2021-01-30 02:46

    Use docstrings.

    This is the built-in suggested convention in PyCharm for describing function using docstring comments:

    def test_function(p1, p2, p3):
        """
        test_function does blah blah blah.
    
        :param p1: describe about parameter p1
        :param p2: describe about parameter p2
        :param p3: describe about parameter p3
        :return: describe what it returns
        """ 
        pass
    

提交回复
热议问题