函数-Ⅶ_lambda表达式
>>> def squareX(x):... return x * x
...
>>> squareX(3)
9
>>> squareY = lambda y : y * y
>>> squareY(3)
9
>>> # 传统定义的函数,函数名就是一个函数的引用:
>>> squareX
<function squareX at 0x01997778>
>>> # 而 lambda 表达式,整个表达式就是一个函数的引用:
>>> squareY
<function <lambda> at 0x01AAA340>
>>> y =
>>> y
[<function <lambda> at 0x01AAA2F8>, 2, 3]
>>> y(y)
4
>>> print(y)
[<function <lambda> at 0x01AAA2F8>, 2, 3]
>>> y(y)
9
>>> list(filter(lambda x : x % 2, range(10)))
{:5_106:} {:5_106:}
页:
[1]