python - python中的那个名字是什么

标签 python closures anonymous-function lambda

我知道什么是闭包,什么是 lambda 函数,但我想知道它们的名称是什么:

>>> def foo(a, b):
>>>     return a + b
>>>
>>> bar = foo
>>> bar(1, 1)
>>> 2

我只想知道在变量中绑定(bind)一个函数的事实

最佳答案

这叫做 first-class functions.引用维基百科:

Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures. [emphasis is mine]

关于python - python中的那个名字是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18078990/

相关文章:

addEventListener 匿名函数中的 Javascript 变量范围

Javascript 匿名函数 - 定义

python - Django 模型外键无法识别 'QueryString' BaseObject

scheme - 方案/ Racket 中关闭的目的是什么?

Python 格式化 float ,如 Fortran

lua - Lua 中的函数可以在调用之间存储本地值吗?

ios - Swift:运算符 '*' 的使用不明确

javascript - 将匿名返回值直接分配给对象的属性

Python按不同属性过滤对象列表

python - 使用PIL python从白色背景到透明背景