What exactly is “lambda” in Python?
问题 I want to know what exactly is lambda in python? and where and why it is used. thanks 回答1: Lambda is more of a concept or programming technique then anything else. Basically it's the idea that you get a function (a first-class object in python) returned as a result of another function instead of an object or primitive type. I know, it's confusing. See this example from the python documentation: def make_incrementor(n): return lambda x: x + n f = make_incrementor(42) f(0) >>> 42 f(1) >>> 43 So