New submission from Jurjen N.E. Bos: When looking for a "neat" way to create an empty generator, I saw on stackOverflow that the crowd wasn't sure what was the "least ugly" way to do it. Proposals where: def emptyIter(): return; yield or def emptyIter(): return iter([])
Then it struck me that a trivial extension to the iter() built-in would be to allow to call it without arguments, thus giving a simple to understand empty iterator, and allowing: def emptyIter(): return iter() (And, of course, this function would not need to exist in any reasonable program in that case.) The implementation would be trivial, I assume. ---------- components: Library (Lib) messages: 251324 nosy: jneb priority: normal severity: normal status: open title: Simple extension to iter(): iter() returns empty generator type: enhancement versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25215> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com