On Fri, 04 May 2018 15:27:16 +0200, Antoon Pardon wrote: >> I might be slow today, but I cannot see how to write a clear, obvious, >> efficient lambda that provides functionality equivalent to itemgetter >> with a default value. [...]
> This seems to work: > > f = (lambda seq: (list(seq) + 3 * ["spam"])[2]) Yep, I'm definitely slow today. Thanks for that. Of course, it's also pretty slow, nearly as slow as me :-) On my computer, it was about 2000% slower than itemgetter using a moderate sized list (100 items). -- Steve -- https://mail.python.org/mailman/listinfo/python-list