What is first class function in Python

前端 未结 8 1242
情话喂你
情话喂你 2020-12-08 10:28

I am still confused about what first-class functions are. If I understand correctly, first-class functions should use one function as an object. Is

8条回答
  •  独厮守ぢ
    2020-12-08 10:57

    This is a good example to illustrate Python first-class functions in their classical form: a variable holding a lambda function:

    twice = lambda x: 2 * x
    d = twice(5)
    print(d)  # 10
    

提交回复
热议问题