gpt4 book ai didi

python - Python function 关键字有什么作用?

转载 作者:太空宇宙 更新时间:2023-11-04 06:50:23 25 4
gpt4 key购买 nike

我在看 this line of code -

    result = function(self, *args, **kwargs)

而且我找不到 Python 的 function 关键字的定义。有人可以将我链接到文档和/或解释这行代码吗?我直觉地认为我知道,但我不明白为什么我找不到任何关于它的文档。

在搜索http://docs.python.org两者 the new module及其继任者types似乎与它有关。

最佳答案

那是因为 function 不是 python 关键字。

如果稍微展开 View ,您会看到 function 是一个变量(作为参数传入)。

def autoAddScript(function):
"""
Returns a decorator function that will automatically add it's result to the element's script container.
"""
def autoAdd(self, *args, **kwargs):
result = function(self, *args, **kwargs)
if isinstance(result, ClientSide.Script):
self(result)
return result
else:
return ClientSide.Script(ClientSide.var(result))
return autoAdd

关于python - Python function 关键字有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21434378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com