
Dec. 15, 2019
8:13 p.m.
On Sun, Dec 15, 2019 at 12:08 PM Tim Peters <tim.peters@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