Advertisement
NickG

Untitled

Sep 29th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. class MapObject:
  2.     def __init__(self, function, *iterables):
  3.         self.function = function
  4.         self.iterables = iterables
  5.  
  6.     def __iter__(self):
  7.         for args in zip(*self.iterables):
  8.             yield self.function(*args)
  9.  
  10. obj = MapObject(print, [1,2], ['a','b'])
  11. obj2 = map(print, [1,2], ['a','b'])
  12.  
  13.  
  14. for _ in obj:
  15.     pass
  16.  
  17. for _ in obj2:
  18.     pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement