Is there builtin code that indexes a list via an index function? Or do I have to do this:
def index(alist, keyExtractor):
result = dict()
for item in alist:
key = keyExtractor(item)
if key is not None:
result[key] = item
return result
You probably want to use a dictionary comprehension: