Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Obj(object):
- def __init__(self):
- pass
- objs = [Obj(), Obj()]
- nums = [1,2]
- for i in range(2):
- objs[i].func = lambda x: nums[i]
- assert ([objs[k].func(0) for k in range(2)]) == nums
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement