Well there is already a function you can call for these, __getitem__:
lst_getter =
lst.__getitem__
map(
lst_getter, idxs)
sorted(range(len(lst)), key=lst_getter)
max(range(len(lst)), key=lst_getter)
dct_getter = dct.__getitem__
map(dct, lst) instead of (dct[l] for l in lst)
If you find yourself preferring this map() style of code a lot (rather than using generator expressions), you can make a utility function:
def getter(obj):
return obj.__getitem__
If anything is going to be proposed, I'd suggest rather than making these callable directly, add a utility function that calls the dunder method.
So:
len() is to __len__
as:
getter() is to __getitem__
But I'm not proposing this, I'm just suggesting it as a bit better alternative to the initial idea.
---
Ricky.
"I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler