
On Fri, Dec 13, 2019 at 09:24:20AM +0200, Serhiy Storchaka wrote:
12.12.19 03:22, Stephen J. Turnbull пише:
I would prefer that it not be implemented at all, but if it is implemented, its behavior should respect the intuition of the majority of those who want it, which seems to me to be "a variant of next() that doesn't raise and returns None by default on an empty iterable."
This is not what the majority expects and is not how first() from more-itertools works.
I don't know who this majority is, or how you know they are a majority, but in this thread, the OP Juancarlo's implementation behaved as Stephen suggested; Guido's version behaved as Stephen suggested; my version behaved as Stephen suggested. I don't recall who wants a version of first that raises, or when that would be useful. It would greatly limit it's usefulness in expressions, since it needs to be guarded by a try...except. -- Steven