itemgetter with default arguments
Antoon Pardon
antoon.pardon at vub.be
Mon May 7 03:56:49 EDT 2018
On 05-05-18 09:33, Peter Otten wrote:
> I think you have established that there is no straight-forward way to write
> this as a lambda. But is adding a default to itemgetter the right
> conclusion?
>
> If there were an exception-catching decorator you could write
>
> f = catch(IndexError, "spam")(itemgetter(2))
I think your catch function would be a usefull addition, but I don't see
it solving this problem once we use itemgetter te get multiple entries.
--
Antoon.
More information about the Python-list
mailing list