Jim Jewett wrote: > I still don't see why it needs to be a return statement. Why not make > the intent of g explicit > > def g(): > yield 42 > raise StopIteration(43) Because it would be tedious and ugly, and would actually make the intent *less* clear in the intended use cases. When writing a suspendable function, you're not thinking about iteration. You're thinking about writing a function that performs some computation and possibly returns a value when finished. Have you seen my multithreaded server example? Do you really think the intent of the code would be any clearer if all the returns were replaced by raising StopIteration? -- Greg
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