What is first class function in Python

前端 未结 8 1266
情话喂你
情话喂你 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:53

    def pie(r):
        def circleArea(d):
            return r * (d ** 2)
        return circleArea
    
    c = pie(3.14)
    print c(2)
    

    Above is an example for first class function in python.

提交回复
热议问题