New submission from Andrew Black <apbl...@pdx.edu>:
The documentation for the built-in function next (which calls the __next__ method on an iterator) discusses its behavior when the iterator is exhausted. It talks about the StopIteration exception. However, it does not say anything about calling next with two arguments. See the library documentation at https://docs.python.org/3/library/stdtypes.html#iterator-types My impression was that the presence of the second argument would suppress the StopIteration exception; instead next would return the value of the second argument. That is the way that list iterators behave, for example. This behavior should be documented. ---------- assignee: docs@python components: Documentation messages: 368525 nosy: Andrew Black, docs@python priority: normal severity: normal status: open title: Second argument to iterator.next not described type: behavior versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40579> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com