How to document python function parameter types?

前端 未结 6 1328
名媛妹妹
名媛妹妹 2020-12-15 05:40

I know that the parameters can be any object but for the documentation it is quite important to specify what you would expect.

First is how to specify a parameter ty

6条回答
  •  感情败类
    2020-12-15 06:27

    If using Python 3, you can use the function annotations described in PEP 3107.

    def compile(
       source: "something compilable",
       filename: "where the compilable thing comes from",
       mode: "is this a single statement or a suite?"):
    

    See also function definitions.

提交回复
热议问题