Nick Coghlan wrote: > Sometimes I miss the obvious. There's a *much*, *much* better place to store > the return value of a generator than on the StopIteration exception that it > raises when it finishes. Just save the return value in the *generator*. I'm not convinced that this is better, because it would make value-returning something specific to generators. On the other hand, raising StopIteration(value) is something that any iterator can easily do, whether it's implemented as a generator, a Python class, a C type, or whatever. Besides, it doesn't smell right to me -- sort of like returning a value from a function by storing it in a global rather than using a return statement. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg.ewing at canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4