A
A B Carter
I have two lists. The values of the second list can be viewed as keys
for the first. I want to create a newlist based on the implied
mapping. The straight Python code would be:
newlist=[]
for key in keys:
newlist.append(oldlist[key])
What's the most efficient way of doing this? The best I could do was
the following list comprehension:
[oldlist[key] for key in keys]
Have I missed something?
Regards, A B Carter
for the first. I want to create a newlist based on the implied
mapping. The straight Python code would be:
newlist=[]
for key in keys:
newlist.append(oldlist[key])
What's the most efficient way of doing this? The best I could do was
the following list comprehension:
[oldlist[key] for key in keys]
Have I missed something?
Regards, A B Carter