1 def multiplier(factor):
2 def multiply_by_factor(number):
3 return number * factor
4 return multiply_by_factor
5
6
7 double = multiplier(2) # factor = 2
8 print(double(5)) # number = 5
9 triple = multiplier(3) # factor = 3
10 print(triple(4)) # number = 4
11 print(multiplier(5)(4))# factor = 5, number = 4
输出:
>>>
10
12
20
posted on 2013-05-16 21:18
unixfy 阅读(166)
评论(0) 编辑 收藏 引用