Tuesday, 17 September 2013

Check many keys in dictionary: optimization

Check many keys in dictionary: optimization

Is there a better way to write the following:
if "msg" in response_dic or "save_act_errors" in response_dic or
"add_act_errors" in response_dic or "modif_act_errors" in response_dic
or "update_act_errors" in response_dic:
#do stuff
response_dic is a dictionary, I am checking for keys.

No comments:

Post a Comment