I had a disgusting thought just now. I needed to have some Python code check whether a dictionary contains a particular key/value pair. The obvious approach,
if dictionary[key] == value:
isn't sufficient, because I need to not throw an exception if the dictionary doesn't contain any mapping for that key at all.
An obvious way is to use a second clause
(
Read more... )