Anonymous function using python (not so simple)

The following is the use of several anonymous function: 
X = [(the lambda X: X ** 2) (X) for X in Range (10)]
Print (X)
Y = [X 2 for X in Range ** (10 )]
Print (Y)
init_data = { 'A':. 1, 'C': 2, 'B':. 5, 'D':. 3, 'E':}. 4
Print (the sorted (init_data.items (), Key the lambda X =: X [. 1]))
Print (the sorted (init_data.items (), the lambda Key = X: X))
Print ((the lambda X: X + 323) (. 3))
#lambda and often map, filter , reduce the use of
map (lambda x: x * 2 , [1,2,3]) #map (func, iter1), func is a simple function of lambda written, iter1 objects is iterative
#filter (function, iterable )

, for example, the following operations:
for X in Range (. 5):
li.append (lambda X: X ** 2)

that is stored inside li data actually stored is the position of lambda, rather than specific data
li [0 ] (2)
Li [}. 1 (2) values of these two functions are the same

python anonymous function is not so simple https: //blog.csdn.net/zwhut/article/details/78417546

Guess you like

Origin www.cnblogs.com/yingchen/p/10962453.html