Re: [Python-Dev] New PEP 342 suggestion: result() and allow return with arguments in generators (was Re: PEP 342 suggestion: start(), __call__() and unwind_call() methods)

2005-10-10 Thread Nick Coghlan
Greg Ewing wrote: 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

Re: [Python-Dev] New PEP 342 suggestion: result() and allow return with arguments in generators (was Re: PEP 342 suggestion: start(), __call__() and unwind_call() methods)

2005-10-10 Thread Guido van Rossum
On 10/10/05, Nick Coghlan [EMAIL PROTECTED] wrote: I'm starting to think we want to let PEP 342 bake for at least one release cycle before deciding what (if any) additional behaviour should be added to generators. Yes please! -- --Guido van Rossum (home page: http://www.python.org/~guido/)

[Python-Dev] New PEP 342 suggestion: result() and allow return with arguments in generators (was Re: PEP 342 suggestion: start(), __call__() and unwind_call() methods)

2005-10-09 Thread Nick Coghlan
Nick Coghlan wrote: Although, if StopIteration.result was a read-only property with the above definition, wouldn't that give us the benefit of one obvious way to return a value from a coroutine without imposing any runtime cost on normal use of StopIteration to finish an iterator?

Re: [Python-Dev] New PEP 342 suggestion: result() and allow return with arguments in generators (was Re: PEP 342 suggestion: start(), __call__() and unwind_call() methods)

2005-10-09 Thread Guido van Rossum
On 10/9/05, Nick Coghlan [EMAIL PROTECTED] 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*. And then provide a

Re: [Python-Dev] New PEP 342 suggestion: result() and allow return with arguments in generators (was Re: PEP 342 suggestion: start(), __call__() and unwind_call() methods)

2005-10-09 Thread Greg Ewing
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