performance differences are negligible, but more importantly, lambda
functions only support expressions, where's def statements can have
any combination of complex statements in their body. The only purpose
of lambda is for convenience, usually as an argument to a higher order
function, and if you assign lambda functions to a name, that negates
their only use case. Indeed, although it is allowed, it is explicitly
recommended against by PEP8 style guidelines.
~ juanpa.arrivillaga
两者的作用相同,但都不是方法;第一个是函数,第二个是匿名函数,通过将其赋给变量来命名。你知道吗
评论:
相关问题 更多 >
编程相关推荐