webexcess
Joined 15 years ago
Karma
363
Submissions
13
Member since
Feb 17
Joined 15 years ago
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.
There are other drawbacks to exec though, some people have disabled exec for security reasons and it's opaque to things like pypy.
The usual #python response to people using the array module was to instead consider NumPy (with its excellent arrays) or use normal lists and PyPy to make it fast.
The same conversion for the later examples with multiple yield statements, try: except: or try: finally: will be much hairier, though.