Looking in the documentation, only the StopIteration raises. I'd like a hasNext() too. I'll see if it is easy to implement, but maybe it'sn ot yet there coz for does the work greatly.
2010/10/21, Kelson Zawack <zawack...@gis.a-star.edu.sg>: > I have been programing in python for a while now and by in large love > it. One thing I don't love though is that as far as I know iterators > have no has_next type functionality. As a result if I want to iterate > until an element that might or might not be present is found I either > wrap the while loop in a try block or break out of a for loop. Since an > iterator having an end is not actually an exceptional case and the for > construct is really for iterating though the entirety of a list both of > these solutions feel like greasy workarounds and thus not very > pythonic. Is there something I am missing? Is there a reason python > iterators don't have has_next functionality? What is the standard > solution to this problem? > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Felipe Bastos Nunes -- http://mail.python.org/mailman/listinfo/python-list