Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # in stackless python or pypy
- def repeat(item):
- i = 0
- while True:
- yield i, item
- i += 1
- import pickle
- gen = repeat('foo')
- print gen.next() # (0, 'foo')
- dumped = pickle.dumps(gen)
- # and in another machine
- gen = pickle.loads(dumped)
- print gen.next() # (1, 'foo')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement