News for hackers. Stuff that matters.
Re:Python Generators in Depth by wookietrader on Tuesday February 26, 2013 @12:33PM (#5287013)
If they could only be pickled...
Re:Python Generators in Depth by webexcess on Tuesday February 26, 2013 @12:43PM (#5287077)
That's a feature!

Seriously though, not being able to define a serialization method can be a limitation. However, it is always possible to turn a generator into an iterator class with whatever methods you like, but the code may end up looking totally different.

Re:Python Generators in Depth by wookietrader on Tuesday February 26, 2013 @02:58PM (#5288092)
To me it only looks like a limitation.

So yeah, you can write a custom class. But you will need to add a custom "save state" and "load state" in your class' __iter__ method. So all the benefits go away.