
On Mon, Dec 09, 2019 at 12:35:28PM -0600, Tim Peters wrote:
I would _much_ rather write - and read:
a = first(iterable, default)
than
a = take(1, iterable, default)[0]
for much the same reasons I'd much rather write and read "2" than "int(10 / 5)" ;-)
Fair enough. If you're binding directly to a result, you can avoid the subscripting by using sequence unpacking, which might look nicer: (a,) = take(1, iterable, default) or write your own one-liner helper :-) I'm thinking that, given Raymond's long reluctance to add additional functions to itertools, it might be easier to add `take` since it is a strictly more powerful function than `first`. If we can only get one, I'd go for `take` since it can do everything `first` would do and more. -- Steven