On Oct 3, 2005, at 1:53 AM, Piet Delport wrote:
> For generators written in this style, "yield" means "suspend  
> execution of the
> current call until the requested result/resource can be provided", and
> "return" regains its full conventional meaning of "terminate the  
> current call
> with a given result".
>
> The simplest / most straightforward implementation would be for  
> "return Foo"
> to translate to "raise StopIteration, Foo". This is consistent with  
> "return"
> translating to "raise StopIteration", and does not break any existing
> generator code.
>
> (Another way to think about this change is that if a plain  
> StopIteration means
> "the iterator terminated", then a valued StopIteration, by  
> extension, means
> "the iterator terminated with the given value".)
>

It sounds like a nice idea to me. Of course, it is only useful to  
functions calling ".next()" explicitly; in something like a for loop,  
the return value would just be ignored.

James
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to