Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If they could only be pickled...


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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: