Advertisement
waltermilner

Untitled

Aug 18th, 2013
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. def multiplier(f):
  2.     def times(n):
  3.         # is f local?
  4.         nonlocal f
  5.         f=f+1
  6.         # if not, why is it here?
  7.         print("Locals: ",locals())
  8.         return n*f  
  9.     return times
  10.  
  11. times2 = multiplier(2)
  12. print(times2(4)) # 3X4=12
  13. print(times2(4)) # 4X4=16
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement