Greg Ewing schrieb:
> Ka-Ping Yee wrote:
> 
>>     Just like getattr, two-argument next(iter, sentinel)
>>     returns sentinel if StopException is caught.
> 
> +1. I've written a number of pieces of code where this
> would have made things neater. Just about any place
> where I've used .next() explicitly, in fact -- it
> always seems awkward having to deal with StopIteration.

Indeed, you almost always have to have a try-except StopIteration-
wrapper around "manual" calls to .next(). In many of these cases,
a default value would make things nicer: +1.

Georg

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

Reply via email to