技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

2013年8月8日 #

python的闭包以及闭包在设计里的意图和作用

摘要: def test(func): print func(3,4) test(lambda x,y : x+y)test(lambda x,y : x-y)这是python的一种闭包写法,他的设计意图是保证test函数代码是稳定的,将容易变化的代码从test提取出去,而这些容易变化的代码如果不复杂,可以采用更轻量级的lambda直接定义,从而减少函数数量,降低程序复杂度 阅读全文

posted @ 2013-08-08 10:02 codestyle 阅读(332) 评论(0) 推荐(0)