This is how I have been searching for objects in python. Is there any more efficient (faster, simpler) way of doing it?
Obs: A is a known object.
for i in Very_Long_List_Of_Names:
if A == My_Dictionary[i]:
print: "The object you are looking for is ", i
break
The one liner would be:
(i for i in List_of_names if A == My_dictionary[i]).next().This throws a
KeyErrorif there is an item inList_of_namesthat is not a key inMy_dictionaryand aStopIterationif the item is not found, else returns the key where it finds A.