Re: [Python-Dev] Please reconsider PEP 479.

2014年11月26日 08:09:55 -0800

On 11/26/2014 12:24 PM, Nick Coghlan wrote:
Now needs to be written out explicitly as:
 def my_generator():
 ...
 try:
 yield next(it)
 except StopIteration
 return
 ...
To retrieve a single value from an iterator, one can use the for/break/else idiom:
def my_generator():
 ...
 for val in it:
 yield val
 break
 else:
 return
 ...
In general, catching and raising StopIteration feels like something that should rarely be done by normal code.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to