On Oct 8, 2005, at 9:10 PM, Nick Coghlan wrote: > So, instead of having "return" automatically map to "raise > StopIteration" > inside generators, I'd like to suggest we keep it illegal to use > "return" > inside a generator Only one issue with that: it's _not currently illegal_ to use return inside a generator. From the view of the outsider, it currently effectively does currently map to "raise StopIteration". But not on the inside, just like you'd expect to happen. The only proposed change to the semantics is to also allow a value to be provided with the return. > def generator(): > yield > try: > return > except StopIteration: > print "But we would get here!" >>> def generator(): ... yield 5 ... try: ... return ... except StopIteration: ... print "But we would get here!" ... >>> x=generator() >>> x.next() 5 >>> x.next() Traceback (most recent call last): File "<stdin>", line 1, in ? StopIteration >>> James
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