如何记录参数是python

时间:2017-06-28 14:29:19

标签: python pydoc

def method(*, var_param, function_param):
    """Call 'function_param' with 'var_param'

    :param var_param: the value to pass to the function_param
    :type log: str
    :param function_param: the method to call with var_param
    :type function_param: ?????
    :return: Nothing
    :rtype: None
    """
    function_param(var_param)

我正在使用pycharm 2017.1.1进行编码,我想知道我需要在:type function_param:中添加什么来表示参数是'函数'?

==编辑==

我尝试使用function,但pycharm抱怨:

screen shot from pycharm

1 个答案:

答案 0 :(得分:2)

您可以使用“可调用”类型。

def method(*, var_param, function_param):
    """Call 'function_param' with 'var_param'

    :param var_param: the value to pass to the function_param
    :type log: str
    :param function_param: the method to call with var_param
    :type function_param: callable[str]
    :return: Nothing
    :rtype: None
    """
    function_param(var_param)

由于您的参数是str,您可以在函数签名中设置它。

更多信息: