SHARE
TWEET

Untitled

a guest Jan 12th, 2013 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Obj(object):
  2.     def __init__(self):
  3.         pass
  4.  
  5. objs = [Obj(), Obj()]
  6. nums = [1,2]
  7.  
  8. for i in range(2):
  9.     objs[i].func = lambda x: nums[i]
  10.  
  11. assert ([objs[k].func(0) for k in range(2)]) == nums
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top