On Sun, Dec 15, 2019 at 12:08 PM Tim Peters <tim.pet...@gmail.com> wrote:
> > Tim: what version do you have in mind? > > Same as always: exactly what more-itertools has supplied for years > already :-) > > If the iterable is empty/exhausted, by default ValueError is raised, > but that can be overridden by also passing an optional argument to > return instead (like dict.pop() in this respect). > > So, e.g., > > first([42]) returns 42 > first([]) raises ValueError > first([], 42) and first([], default=42) return 42 > perfect -- thanks -- we now have a concrete proposal +1 from me. :-) -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/WXZ47QIVZHTFL3NXSZFTGF5YD6KTQVBO/ Code of Conduct: http://python.org/psf/codeofconduct/